This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][C++] Fix PR61004
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Thu, 5 Jun 2014 14:19:26 +0200
- Subject: Re: [PATCH][C++] Fix PR61004
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1404301356230 dot 18709 at zhemvz dot fhfr dot qr> <alpine dot LSU dot 2 dot 11 dot 1405061255100 dot 18709 at zhemvz dot fhfr dot qr>
On Tue, May 6, 2014 at 12:55 PM, Richard Biener <rguenther@suse.de> wrote:
> On Wed, 30 Apr 2014, Richard Biener wrote:
>
>>
>> With no longer recording alias subsets using BINFOs we now emit
>> bogus alias warnings for accessing empty bases. The following
>> avoids this, accessing those with an incompatible alias-set is
>> harmless.
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?
>
> Ping.
Ping.
Thanks,
RIchard.
>> Thanks,
>> Richard.
>>
>> 2014-04-30 Richard Biener <rguenther@suse.de>
>>
>> PR c++/61004
>> * typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing
>> warnings for accessing empty classes.
>>
>> * g++.dg/diagnostic/pr61004.C: New testcase.
>>
>> Index: gcc/cp/typeck.c
>> ===================================================================
>> --- gcc/cp/typeck.c (revision 209928)
>> +++ gcc/cp/typeck.c (working copy)
>> @@ -2921,8 +2921,9 @@ cp_build_indirect_ref (tree ptr, ref_ope
>> of the result is "T." */
>> tree t = TREE_TYPE (type);
>>
>> - if (CONVERT_EXPR_P (ptr)
>> - || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
>> + if ((CONVERT_EXPR_P (ptr)
>> + || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
>> + && (!CLASS_TYPE_P (t) || !CLASSTYPE_EMPTY_P (t)))
>> {
>> /* If a warning is issued, mark it to avoid duplicates from
>> the backend. This only needs to be done at
>> Index: gcc/testsuite/g++.dg/diagnostic/pr61004.C
>> ===================================================================
>> --- gcc/testsuite/g++.dg/diagnostic/pr61004.C (revision 0)
>> +++ gcc/testsuite/g++.dg/diagnostic/pr61004.C (working copy)
>> @@ -0,0 +1,11 @@
>> +// { dg-do compile }
>> +// { dg-options "-O2 -Wall" }
>> +
>> +struct A{ };
>> +struct B:A{};
>> +void f(A const&);
>> +int main()
>> +{
>> + B b;
>> + f(b); // { dg-bogus "strict-aliasing" }
>> +}
>>