* PR54442 build_qualified_type produces a non-canonical type
@ 2014-06-09 14:18 Marc Glisse
2014-06-09 14:24 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Marc Glisse @ 2014-06-09 14:18 UTC (permalink / raw)
To: gcc-patches; +Cc: jason
[-- Attachment #1: Type: TEXT/PLAIN, Size: 712 bytes --]
Hello,
in this PR, we end up with 3 types A, B and C such that
TYPE_CANONICAL(A)=B and TYPE_CANONICAL(B)=C. I don't think that is
supposed to happen. Here, build_qualified_type fills in TYPE_CANONICAL(A)
by calling build_qualified_type (so get_qualified_type), which afaics
isn't guaranteed to return a canonical type.
I doubt the patch can be wrong, but it may be that this is a situation
that is not supposed to happen and should be fixed elsewhere?
Bootstrap+testsuite on x86_64-linux-gnu.
2014-06-09 Marc Glisse <marc.glisse@inria.fr>
PR c++/54442
gcc/
* tree.c (build_qualified_type): Use a canonical type for
TYPE_CANONICAL.
gcc/testsuite/
* g++.dg/pr54442.C: New file.
--
Marc Glisse
[-- Attachment #2: Type: TEXT/PLAIN, Size: 1384 bytes --]
Index: gcc/testsuite/g++.dg/pr54442.C
===================================================================
--- gcc/testsuite/g++.dg/pr54442.C (revision 0)
+++ gcc/testsuite/g++.dg/pr54442.C (working copy)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+struct S
+{
+ void s (int) const throw ();
+ void s (int) throw ();
+};
+
+typedef int index_t;
+
+void (S::*f) (index_t) = &S::s;
+void (S::*g) (index_t) const = &S::s;
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 211374)
+++ gcc/tree.c (working copy)
@@ -6319,22 +6319,25 @@ build_qualified_type (tree type, int typ
TYPE_ALIGN (t) = TYPE_ALIGN (atomic_type);
}
}
if (TYPE_STRUCTURAL_EQUALITY_P (type))
/* Propagate structural equality. */
SET_TYPE_STRUCTURAL_EQUALITY (t);
else if (TYPE_CANONICAL (type) != type)
/* Build the underlying canonical type, since it is different
from TYPE. */
- TYPE_CANONICAL (t) = build_qualified_type (TYPE_CANONICAL (type),
- type_quals);
+ {
+ tree c = build_qualified_type (TYPE_CANONICAL (type),
+ type_quals);
+ TYPE_CANONICAL (t) = TYPE_CANONICAL (c);
+ }
else
/* T is its own canonical type. */
TYPE_CANONICAL (t) = t;
}
return t;
}
/* Create a variant of type T with alignment ALIGN. */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PR54442 build_qualified_type produces a non-canonical type
2014-06-09 14:18 PR54442 build_qualified_type produces a non-canonical type Marc Glisse
@ 2014-06-09 14:24 ` Jason Merrill
2014-06-09 14:32 ` Marc Glisse
0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2014-06-09 14:24 UTC (permalink / raw)
To: Marc Glisse, gcc-patches
On 06/09/2014 10:18 AM, Marc Glisse wrote:
> I doubt the patch can be wrong, but it may be that this is a situation
> that is not supposed to happen and should be fixed elsewhere?
Seems likely. What is the difference between the type returned from
build_qualified_type (TYPE_CANONICAL and it's TYPE_CANONICAL? I would
expect them to be the same.
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PR54442 build_qualified_type produces a non-canonical type
2014-06-09 14:24 ` Jason Merrill
@ 2014-06-09 14:32 ` Marc Glisse
2014-06-09 14:46 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Marc Glisse @ 2014-06-09 14:32 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
On Mon, 9 Jun 2014, Jason Merrill wrote:
> On 06/09/2014 10:18 AM, Marc Glisse wrote:
>> I doubt the patch can be wrong, but it may be that this is a situation
>> that is not supposed to happen and should be fixed elsewhere?
>
> Seems likely. What is the difference between the type returned from
> build_qualified_type (TYPE_CANONICAL and it's TYPE_CANONICAL? I would expect
> them to be the same.
throws <tree_list 0x7ffff660e5c8
purpose <integer_cst 0x7ffff64d6ba0 constant 1>>>
(in what build_qualified_type returns)
--
Marc Glisse
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PR54442 build_qualified_type produces a non-canonical type
2014-06-09 14:32 ` Marc Glisse
@ 2014-06-09 14:46 ` Jason Merrill
2015-01-13 19:01 ` Paolo Carlini
0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2014-06-09 14:46 UTC (permalink / raw)
To: Marc Glisse; +Cc: gcc-patches
On 06/09/2014 10:32 AM, Marc Glisse wrote:
> On Mon, 9 Jun 2014, Jason Merrill wrote:
>
>> On 06/09/2014 10:18 AM, Marc Glisse wrote:
>>> I doubt the patch can be wrong, but it may be that this is a situation
>>> that is not supposed to happen and should be fixed elsewhere?
>>
>> Seems likely. What is the difference between the type returned from
>> build_qualified_type (TYPE_CANONICAL and it's TYPE_CANONICAL? I would
>> expect them to be the same.
>
> throws <tree_list 0x7ffff660e5c8
> purpose <integer_cst 0x7ffff64d6ba0 constant 1>>>
>
> (in what build_qualified_type returns)
I guess that makes sense, given that the exception specification isn't
really part of the type. The patch is OK.
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PR54442 build_qualified_type produces a non-canonical type
2014-06-09 14:46 ` Jason Merrill
@ 2015-01-13 19:01 ` Paolo Carlini
2015-01-13 21:25 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Carlini @ 2015-01-13 19:01 UTC (permalink / raw)
To: Jason Merrill, Marc Glisse; +Cc: gcc-patches
Hi,
On 06/09/2014 04:46 PM, Jason Merrill wrote:
> On 06/09/2014 10:32 AM, Marc Glisse wrote:
>> On Mon, 9 Jun 2014, Jason Merrill wrote:
>>
>>> On 06/09/2014 10:18 AM, Marc Glisse wrote:
>>>> I doubt the patch can be wrong, but it may be that this is a situation
>>>> that is not supposed to happen and should be fixed elsewhere?
>>>
>>> Seems likely. What is the difference between the type returned from
>>> build_qualified_type (TYPE_CANONICAL and it's TYPE_CANONICAL? I would
>>> expect them to be the same.
>>
>> throws <tree_list 0x7ffff660e5c8
>> purpose <integer_cst 0x7ffff64d6ba0 constant 1>>>
>>
>> (in what build_qualified_type returns)
>
> I guess that makes sense, given that the exception specification isn't
> really part of the type. The patch is OK.
In fact, I noticed today that this is a 4.8/4.9 Regression too. Shall I
try to apply the patchlet to 4_9-branch too and, if testing passes,
commit there and close the bug?
Thanks,
Paolo.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-01-13 21:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-09 14:18 PR54442 build_qualified_type produces a non-canonical type Marc Glisse
2014-06-09 14:24 ` Jason Merrill
2014-06-09 14:32 ` Marc Glisse
2014-06-09 14:46 ` Jason Merrill
2015-01-13 19:01 ` Paolo Carlini
2015-01-13 21:25 ` 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).