Bug 82872 - [6/7 regression] ICE in ignore_overflows on __PTRDIFF_MAX__ index
Summary: [6/7 regression] ICE in ignore_overflows on __PTRDIFF_MAX__ index
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P2 minor
Target Milestone: 8.0
Assignee: Eric Botcazou
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2017-11-07 02:35 UTC by Martin Sebor
Modified: 2017-12-21 16:25 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.3
Known to fail: 4.7.4, 4.8.4, 4.9.4, 5.5.0, 6.4.0, 7.2.0, 8.0
Last reconfirmed: 2017-11-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2017-11-07 02:35:31 UTC
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.
Comment 1 Eric Botcazou 2017-11-07 07:21:07 UTC
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__.
Comment 2 Eric Botcazou 2017-12-15 09:47:30 UTC
Investigating.
Comment 3 Eric Botcazou 2017-12-21 16:22:36 UTC
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
Comment 4 Eric Botcazou 2017-12-21 16:25:57 UTC
No backport planned.