* [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410)
@ 2018-12-09 11:05 Jakub Jelinek
2018-12-17 18:58 ` Patch ping (was Re: [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410)) Jakub Jelinek
2018-12-17 21:00 ` [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410) Jason Merrill
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2018-12-09 11:05 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
The following testcase ICEs starting with my change to move offsetof-like
expression handling from the parsing to cp_fold - if the base expression
is not INTEGER_CST, but a constant VAR_DECL initialized with INTEGER_CST,
then we don't fold it as offsetof-like expression and as we use recursive
cp_fold only on functions, not initializers, we don't fold that VAR_DECL in
there into INTEGER_CST and the middle-end ICEs on it trying to fold it.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2018-12-09 Jakub Jelinek <jakub@redhat.com>
PR c++/88410
* cp-gimplify.c (cp_fold) <case ADDR_EXPR>: For offsetof-like folding,
call maybe_constant_value on val to see if it is INTEGER_CST.
* g++.dg/cpp0x/pr88410.C: New test.
--- gcc/cp/cp-gimplify.c.jj 2018-11-23 20:00:26.603273556 +0100
+++ gcc/cp/cp-gimplify.c 2018-12-08 11:39:03.983985326 +0100
@@ -2317,6 +2317,7 @@ cp_fold (tree x)
{
val = TREE_OPERAND (val, 0);
STRIP_NOPS (val);
+ val = maybe_constant_value (val);
if (TREE_CODE (val) == INTEGER_CST)
return fold_offsetof (op0, TREE_TYPE (x));
}
--- gcc/testsuite/g++.dg/cpp0x/pr88410.C.jj 2018-12-08 11:41:10.946927148 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr88410.C 2018-12-08 11:40:48.476291414 +0100
@@ -0,0 +1,7 @@
+// PR c++/88410
+// { dg-do compile { target c++11 } }
+
+typedef __UINTPTR_TYPE__ uintptr_t;
+const uintptr_t a = 32;
+struct C { int b; int c; };
+uintptr_t d { uintptr_t (&reinterpret_cast<C *>(a)->c) - a };
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Patch ping (was Re: [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410))
2018-12-09 11:05 [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410) Jakub Jelinek
@ 2018-12-17 18:58 ` Jakub Jelinek
2018-12-17 21:00 ` [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410) Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2018-12-17 18:58 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
On Sun, Dec 09, 2018 at 12:05:06PM +0100, Jakub Jelinek wrote:
> The following testcase ICEs starting with my change to move offsetof-like
> expression handling from the parsing to cp_fold - if the base expression
> is not INTEGER_CST, but a constant VAR_DECL initialized with INTEGER_CST,
> then we don't fold it as offsetof-like expression and as we use recursive
> cp_fold only on functions, not initializers, we don't fold that VAR_DECL in
> there into INTEGER_CST and the middle-end ICEs on it trying to fold it.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2018-12-09 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/88410
> * cp-gimplify.c (cp_fold) <case ADDR_EXPR>: For offsetof-like folding,
> call maybe_constant_value on val to see if it is INTEGER_CST.
>
> * g++.dg/cpp0x/pr88410.C: New test.
I'd like to ping this patch.
Thanks.
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410)
2018-12-09 11:05 [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410) Jakub Jelinek
2018-12-17 18:58 ` Patch ping (was Re: [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410)) Jakub Jelinek
@ 2018-12-17 21:00 ` Jason Merrill
1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2018-12-17 21:00 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 12/9/18 6:05 AM, Jakub Jelinek wrote:
> Hi!
>
> The following testcase ICEs starting with my change to move offsetof-like
> expression handling from the parsing to cp_fold - if the base expression
> is not INTEGER_CST, but a constant VAR_DECL initialized with INTEGER_CST,
> then we don't fold it as offsetof-like expression and as we use recursive
> cp_fold only on functions, not initializers, we don't fold that VAR_DECL in
> there into INTEGER_CST and the middle-end ICEs on it trying to fold it.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
OK.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-17 21:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-09 11:05 [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410) Jakub Jelinek
2018-12-17 18:58 ` Patch ping (was Re: [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410)) Jakub Jelinek
2018-12-17 21:00 ` [C++ PATCH] Fix ICE with offsetof-like initializer (PR c++/88410) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).