This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81858] New: Wrong strict-aliasing warning


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.richter@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 )
                ^~~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]