[Bug c++/94951] [8/9/10/11 Regression] dereferencing type-punned pointer will break strict-aliasing rules when using super class for a template type

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 7 13:28:15 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94951

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:d82414ebcf7716ea24688510594a2c464a105908

commit r10-8115-gd82414ebcf7716ea24688510594a2c464a105908
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed May 6 23:38:13 2020 +0200

    c++: Avoid strict_aliasing_warning on dependent types or expressions
[PR94951]

    The following testcase gets a bogus warning during build_base_path,
    when cp_build_indirect_ref* calls strict_aliasing_warning with a dependent
    expression.  IMHO calling get_alias_set etc. on dependent types feels wrong
    to me, we should just defer the warnings in those cases until instantiation
    and only handle the cases where neither type nor expr are dependent.

    2020-05-06  Jakub Jelinek  <jakub@redhat.com>

            PR c++/94951
            * typeck.c (cp_strict_aliasing_warning): New function.
            (cp_build_indirect_ref_1, build_reinterpret_cast_1): Use
            it instead of strict_aliasing_warning.

            * g++.dg/warn/Wstrict-aliasing-bogus-tmpl.C: New test.


More information about the Gcc-bugs mailing list