This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/36369] New: [4.3/4.4 Regression] Type punning warning with may_alias attribute depends on unrelated class definition
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 May 2008 13:13:57 -0000
- Subject: [Bug middle-end/36369] New: [4.3/4.4 Regression] Type punning warning with may_alias attribute depends on unrelated class definition
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#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