[Bug c++/84724] [7/8 Regression] internal compiler error: in single_succ_edge, at basic-block.h:339 with a declaration of __builtin_trap

2018-03-09 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84724

--- Comment #5 from Jakub Jelinek  ---
Author: jakub
Date: Fri Mar  9 18:01:22 2018
New Revision: 258391

URL: https://gcc.gnu.org/viewcvs?rev=258391=gcc=rev
Log:
PR c++/84724
* decl.c (duplicate_decls): Don't override __* prefixed builtins
except for __[^b]*_chk, instead issue permerror and for -fpermissive
also a note and return olddecl.

* g++.dg/ext/pr84724.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/ext/pr84724-1.C
trunk/gcc/testsuite/g++.dg/ext/pr84724-2.C
trunk/gcc/testsuite/g++.dg/ext/pr84724-3.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/84724] [7/8 Regression] internal compiler error: in single_succ_edge, at basic-block.h:339 with a declaration of __builtin_trap

2018-03-08 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84724

--- Comment #4 from Jakub Jelinek  ---
Created attachment 43595
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43595=edit
gcc8-pr84724.patch

Untested fix.

[Bug c++/84724] [7/8 Regression] internal compiler error: in single_succ_edge, at basic-block.h:339 with a declaration of __builtin_trap

2018-03-06 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84724

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||jason at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
The C FE has quite a lot of code in this case, e.g.
match_builtin_function_types, which the C++ FE doesn't seem to have, and indeed
the C FE leaves the __builtin_trap decl untouched after warning, while the C++
FE changes it.

The ICE in this case isn't caused by a mismatch between __builtin_trap ()
return type, but rather the lack of noreturn attribute on the new decl.
Though I'm sure that redefining similar way many other builtins that GCC emits
on its own or expects a particular arguments or return types will cause many
other ICEs.

[Bug c++/84724] [7/8 Regression] internal compiler error: in single_succ_edge, at basic-block.h:339 with a declaration of __builtin_trap

2018-03-06 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84724

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
   Target Milestone|--- |7.4

--- Comment #2 from Richard Biener  ---
Yeah.  Or rather the FEs shouldn't clobber the builtin decls (_not_ merge into
them) so that when the ME looks up decls for them they never pick up user
decls.

Similar issues for builtin folding if the folded-to builtin is misdeclared.

[Bug c++/84724] [7/8 Regression] internal compiler error: in single_succ_edge, at basic-block.h:339 with a declaration of __builtin_trap

2018-03-05 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84724

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-03-06
 CC||msebor at gcc dot gnu.org
  Known to work||6.4.0
Summary|internal compiler error: in |[7/8 Regression] internal
   |single_succ_edge, at|compiler error: in
   |basic-block.h:339   |single_succ_edge, at
   ||basic-block.h:339 with a
   ||declaration of
   ||__builtin_trap
 Ever confirmed|0   |1
  Known to fail||7.3.0, 8.0

--- Comment #1 from Martin Sebor  ---
Confirmed with r244114 (gcc 7.0.0) as the first revision to ICE:

r244114 | jakub | 2017-01-05 16:14:19 -0500 (Thu, 05 Jan 2017) | 12 lines

PR tree-optimization/71016

Prior to that GCC accepted the test case (with -fpermissive):

t.C:2:5: warning: new declaration ‘int __builtin_trap()’ ambiguates built-in
declaration ‘void __builtin_trap()’ [-Wbuiltin-declaration-mismatch]
 int __builtin_trap();
 ^~
t.C: In function ‘int a()’:
t.C:6:9: warning: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
   int c();
 ^~

A simpler test case is

  int __builtin_trap ();

  int a (int i)
  {
const char *p = i < 0 ? 0 : "";

return *p;
  }

The trouble seems to be that __builtin_trap is expected not to return but the
extern C++ declaration in the program says otherwise and overrides the
built-in.  I'd say re-declarations of built-ins that GCC itself depends
on/makes assumptions about should be rejected with a hard error.