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

            Bug ID: 81858
           Summary: Wrong strict-aliasing warning
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joerg.rich...@pdv-fs.de
  Target Milestone: ---

cat > t.cc <<EOF
struct Bar
{
    bool val;
};

struct Baz : Bar
{
    char buf[1];
};

template<class T> struct Quux
{
    void foo() const
    {
      Baz baz;
      if( !baz.val )
      {
      }
    }
};
EOF
g++ -O2 -c t.cc -Wall

t.cc: In member function 'void Quux<T>::foo() const':
t.cc:16:16: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
       if( !baz.val )
                ^~~

Reply via email to