[Bug tree-optimization/86428] strlen of const array initialized with a string of the same length not folded

2018-07-07 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86428

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #2 from Martin Sebor  ---
Patch: https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00377.html

[Bug tree-optimization/86434] early string folding defeats strlen optimization and -Warray-bounds

2018-07-07 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86434

Martin Sebor  changed:

   What|Removed |Added

   Keywords||diagnostic,
   ||missed-optimization
Summary|early string folding|early string folding
   |defeats strlen optimization |defeats strlen optimization
   ||and -Warray-bounds

--- Comment #1 from Martin Sebor  ---
Here's another test showing the consequences of the early folding: In f()
below, the strlen() call isn't folded and so the -Warray-bounds warning has a
chance to detect the out-of-bounds index.  But because the strlen() call is not
folded, the program will behave unpredictably.  Folding the call to zero
instead after the warning has been issued would be safer and result in more
predictable results.  In g(), on the other hand, the early folding prevents the
warning and also leads to a result that's inconsistent with one that would be
obtained by a valid program (also unsafe and difficult to debug).

$ cat d.c && gcc -O2 -S -Wall -Wextra -fdump-tree-strlen=/dev/stdout d.c
const char a[] = "123";

void f (int i)
{
  if (i < 7)
i = 7;

  const char *s = [i];  // -Warray-bounds

  if (__builtin_strlen (s) > 3)   // not folded (bad)
__builtin_puts ("impossible!");
}

void g (int i)
{
  if (i < 7)
i = 7;

  if (__builtin_strlen ([i]) > 3)   // no -Warray-bounds, folded to true
__builtin_puts ("impossible!");
}

d.c: In function ‘f’:
d.c:8:19: warning: array subscript 7 is above array bounds of ‘const char[4]’
[-Warray-bounds]
   const char *s = [i];  // -Warray-bounds
   ^
d.c:3:6: warning: offset ‘7’ outside bounds of constant string [-Warray-bounds]
 void f (int i)
  ^

;; Function f (f, funcdef_no=0, decl_uid=1957, cgraph_uid=0, symbol_order=1)

f (int i)
{
  const char * s;
  long unsigned int _1;
  sizetype _2;

   [local count: 1073741825]:
  i_8 = MAX_EXPR ;
  _2 = (sizetype) i_8;
  s_5 =  + _2;
  _1 = __builtin_strlen (s_5);
  if (_1 > 3)
goto ; [33.00%]
  else
goto ; [67.00%]

   [local count: 354334802]:
  __builtin_puts ("impossible!");

   [local count: 1073741824]:
  return;

}



;; Function g (g, funcdef_no=1, decl_uid=1961, cgraph_uid=1, symbol_order=2)

g (int i)
{
   [local count: 1073741825]:
  __builtin_puts ("impossible!");
  return;

}

[Bug tree-optimization/86434] New: early string folding defeats strlen optimization

2018-07-07 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86434

Bug ID: 86434
   Summary: early string folding defeats strlen optimization
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

When the call to strlen() below is folded to (3 - i) it is done very early, and
without setting the range of the result of the subtraction.  This early folding
prevents later optimizations from determining that the result of the strlen()
call (or that of the subtraction) cannot be greater than 3.  It's an example
that illustrates why early folding should be restricted to constants and leave
more advanced optimizations to later passes that have access to the results of
data flow analyses.

$ cat d.c && gcc -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout d.cconst
char a[] = "123";
const char a[] = "123";

void f (int i)
{
  if (__builtin_strlen ([i]) > 3)
__builtin_abort ();
}

;; Function f (f, funcdef_no=0, decl_uid=1957, cgraph_uid=0, symbol_order=1)

f (int i)
{
  ssizetype _1;
  ssizetype _2;
  long unsigned int _3;

   :
  _1 = (ssizetype) i_4(D);
  _2 = 3 - _1;
  _3 = (long unsigned int) _2;
  if (_3 > 3)
goto ; [INV]
  else
goto ; [INV]

   :
  __builtin_abort ();

   :
  return;

}

[Bug libstdc++/86433] New: Shouldn't non const hashers also be allowed?

2018-07-07 Thread tiagomacarios at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86433

Bug ID: 86433
   Summary: Shouldn't non const hashers also be allowed?
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tiagomacarios at gmail dot com
  Target Milestone: ---

https://godbolt.org/g/Z1cqm9

#include 

struct my_hash {
std::size_t operator() (int const&) /*const*/ {
return {};   // ~
}
};

std::unordered_set temp;

Shouldn't non-const hashers also be allowed?

http://eel.is/c++draft/hash.requirements#2

[Bug target/86383] [9 Regression] arm-netbsdelf cross compiler fails in selftests

2018-07-07 Thread coypu at sdf dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86383

coypu  changed:

   What|Removed |Added

 CC||coypu at sdf dot org

--- Comment #5 from coypu  ---
(In reply to Richard Earnshaw from comment #2)
> I'm not sure how relevant the netbsd-elf port is these days.  I believe
> they've now moved onto an EABI based ABI.  But no GCC port of that has been
> contributed.

hi,

I have a big working patch for netbsd/arm eabi.
I didn't test it against trunk/clean it up yet.
(https://v4.freshbsd.org/commit/netbsd/pkgsrc/yfUHHZvopo2aGFGA)

can I assign this to myself?

[Bug tree-optimization/86274] [7/8 Regression] SEGFAULT when logging std::to_string(NAN)

2018-07-07 Thread floop at floop dot cz
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86274

--- Comment #18 from Filip Matzner  ---
Thank you everyone. Your efficiency is breathtaking.

[Bug c++/86432] New: ICE on capture VLA by reference

2018-07-07 Thread tomilovanatoliy at yandex dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86432

Bug ID: 86432
   Summary: ICE on capture VLA by reference
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tomilovanatoliy at yandex dot ru
  Target Milestone: ---

Code:

#include 

int main(int argc, char * argv[])
{
char * v[argc];
for (int c = 0; c < argc; ++c) {
v[c] = argv[c];
}
[]
{
std::cout << sizeof(v) << std::endl;
}();
}

Error (command line `g++ prog.cc -Wall -Wextra -std=gnu++2a`):

prog.cc: In lambda function:
prog.cc:11:30: warning: '' is used uninitialized in this function
[-Wuninitialized]
 std::cout << sizeof(v) << std::endl;
  ^
during RTL pass: expand
prog.cc:11:30: internal compiler error: in expand_expr_real_1, at expr.c:9907
0x591cb6 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
../../source/gcc/expr.c:9901
0x89c9dd expand_expr
../../source/gcc/expr.h:279
0x89c9dd expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
../../source/gcc/expr.c:8418
0x79d0c7 expand_gimple_stmt_1
../../source/gcc/cfgexpand.c:3673
0x79d0c7 expand_gimple_stmt
../../source/gcc/cfgexpand.c:3734
0x79e75f expand_gimple_basic_block
../../source/gcc/cfgexpand.c:5765
0x7a38c6 execute
../../source/gcc/cfgexpand.c:6368

[Bug c++/86431] Legal code?

2018-07-07 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86431

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||rejects-valid
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-07-07
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
Yes, I think this should be accepted.

[Bug target/84711] AArch32 big-endian fails when taking subreg of a vector mode to a scalar mode.

2018-07-07 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84711

--- Comment #15 from Jakub Jelinek  ---
Author: jakub
Date: Sat Jul  7 07:47:10 2018
New Revision: 262493

URL: https://gcc.gnu.org/viewcvs?rev=262493=gcc=rev
Log:
PR target/84711
* gcc.dg/vect/pr84711.c: Remove unnecessary sse
dg-require-effective-target.  Add -msse not just on i386-*, but
on all i?86-* and x86_64-*.

Modified:
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/vect/pr84711.c