The following program causes an ICE. The likely culprit is r180986 committed in the GCC 4.7.0 cycle. $ cat t.C && gcc -S -Wall -Wextra t.C #include <stddef.h> constexpr int f () { struct S { int i, a[1]; }; return offsetof (S, a[__PTRDIFF_MAX__]); } constexpr int i = f (); In file included from t.C:1:0: t.C: In function ‘constexpr int f()’: t.C:7:10: internal compiler error: in ignore_overflows, at cp/cvt.c:583 return offsetof (S, a[__PTRDIFF_MAX__]); ^~~~~~~~ 0x7fb263 ignore_overflows /ssd/src/gcc/git/gcc/cp/cvt.c:583 0x7fbdd1 ocp_convert(tree_node*, tree_node*, int, int, int) /ssd/src/gcc/git/gcc/cp/cvt.c:817 0x7fda55 convert(tree_node*, tree_node*) /ssd/src/gcc/git/gcc/cp/cvt.c:1580 0x9c041e fold_offsetof(tree_node*) /ssd/src/gcc/git/gcc/c-family/c-common.c:6223 0x93d5ee finish_offsetof(tree_node*, tree_node*, unsigned int) /ssd/src/gcc/git/gcc/cp/semantics.c:4038 0x8a0e05 cp_parser_builtin_offsetof /ssd/src/gcc/git/gcc/cp/parser.c:9930 0x897a31 cp_parser_primary_expression /ssd/src/gcc/git/gcc/cp/parser.c:5335 0x89b2ef cp_parser_postfix_expression /ssd/src/gcc/git/gcc/cp/parser.c:7022 0x89e4de cp_parser_unary_expression /ssd/src/gcc/git/gcc/cp/parser.c:8363 0x89f4e8 cp_parser_cast_expression /ssd/src/gcc/git/gcc/cp/parser.c:9131 0x89f5d8 cp_parser_binary_expression /ssd/src/gcc/git/gcc/cp/parser.c:9232 0x8a0204 cp_parser_assignment_expression /ssd/src/gcc/git/gcc/cp/parser.c:9519 0x8a0585 cp_parser_expression /ssd/src/gcc/git/gcc/cp/parser.c:9688 0x8a586a cp_parser_jump_statement /ssd/src/gcc/git/gcc/cp/parser.c:12474 0x8a2959 cp_parser_statement /ssd/src/gcc/git/gcc/cp/parser.c:10897 0x8a3612 cp_parser_statement_seq_opt /ssd/src/gcc/git/gcc/cp/parser.c:11348 0x8a3508 cp_parser_compound_statement /ssd/src/gcc/git/gcc/cp/parser.c:11302 0x8b4a3f cp_parser_function_body /ssd/src/gcc/git/gcc/cp/parser.c:21839 0x8b4b4a cp_parser_ctor_initializer_opt_and_function_body /ssd/src/gcc/git/gcc/cp/parser.c:21874 0x8bc809 cp_parser_function_definition_after_declarator /ssd/src/gcc/git/gcc/cp/parser.c:26765 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.
Nothing to do with constexpr though: #include <stddef.h> int f (void) { struct S { int i, a[1]; }; return offsetof (struct S, a[__PTRDIFF_MAX__]); } fails the same way. Priority epsilon since only happens for __PTRDIFF_MAX__.
Investigating.
Author: ebotcazou Date: Thu Dec 21 16:22:04 2017 New Revision: 255944 URL: https://gcc.gnu.org/viewcvs?rev=255944&root=gcc&view=rev Log: PR c++/82872 * convert.c (convert_to_integer_1) <POINTER_TYPE>: Do not return the shared zero if the input has overflowed. Added: trunk/gcc/testsuite/c-c++-common/pr82872.c Modified: trunk/gcc/ChangeLog trunk/gcc/convert.c trunk/gcc/testsuite/ChangeLog
No backport planned.