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 middle-end/36369] New: [4.3/4.4 Regression] Type punning warning with may_alias attribute depends on unrelated class definition


#ifdef DEFINE_B
struct B
{
  unsigned long b;
  B &operator= (bool x) { return *this; }
};
#endif
struct A
{
  void *a;
};
bool operator >>= (const A &x, long &y)
{
  typedef long __attribute__ ((may_alias)) long_a;
  y = *reinterpret_cast <const long_a *> (&x.a);
  return true;
}
long test(const A &x)
{
  long a;
  x >>= a;
  return a;
}
issues (IMHO bogus) warning:
rh448897.C:15: warning: dereferencing type-punned pointer will break
strict-aliasing rules
when compiled with -O2 -Wall -DDEFINE_B, but not with -O2 -Wall.


-- 
           Summary: [4.3/4.4 Regression] Type punning warning with may_alias
                    attribute depends on unrelated class definition
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36369


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