[patch] Fix PR C++/82872
Eric Botcazou
ebotcazou@adacore.com
Thu Dec 21 15:52:00 GMT 2017
Hi,
this is an ICE in the C++ FE on an offsetof construct with __PTRDIFF_MAX__ and
it happens only with this specific index:
In file included from pr82872.c:4:
pr82872.c: In function 'size_t foo()':
pr82872.c:10:10: internal compiler error: in ignore_overflows, at cp/cvt.c:583
return offsetof (struct S, a[__PTRDIFF_MAX__]);
^~~~~~~~
0x65ef7f ignore_overflows
/home/eric/svn/gcc/gcc/cp/cvt.c:583
0x661bcc ocp_convert(tree_node*, tree_node*, int, int, int)
/home/eric/svn/gcc/gcc/cp/cvt.c:817
0x6636e0 convert(tree_node*, tree_node*)
/home/eric/svn/gcc/gcc/cp/cvt.c:1580
0x882b62 fold_offsetof(tree_node*)
/home/eric/svn/gcc/gcc/c-family/c-common.c:6282
0x801c0c finish_offsetof(tree_node*, tree_node*, unsigned int)
/home/eric/svn/gcc/gcc/cp/semantics.c:4041
0x74596b cp_parser_builtin_offsetof
/home/eric/svn/gcc/gcc/cp/parser.c:9828
The C++ FE is quite picky about constant integer overflow during conversion
operations and checks that they can only _introduce_ overflows and never make
them disappear, the latter case occuring here in convert_to_integer_1.
Tested on x86_64-suse-linux, OK for the mainline?
2017-12-21 Eric Botcazou <ebotcazou@adacore.com>
PR C++/82872
* convert.c (convert_to_integer_1) <POINTER_TYPE>: Do not return
the shared zero if the input has overflowed.
2017-12-21 Eric Botcazou <ebotcazou@adacore.com>
* c-c++-common/pr82872.c: New test.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr82872.c
Type: text/x-csrc
Size: 165 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20171221/7b1bbf1f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr82872.diff
Type: text/x-patch
Size: 469 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20171221/7b1bbf1f/attachment-0001.bin>
More information about the Gcc-patches
mailing list