[Bug c++/69843] New: C++: Inconsistent treatment of may_alias attribute and forward declarations
fw at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 16 17:29:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69843
Bug ID: 69843
Summary: C++: Inconsistent treatment of may_alias attribute and
forward declarations
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fw at gcc dot gnu.org
Target Milestone: ---
This is a bit inconsistent. I would expect an error on the definition because
it is inconsistent with the forward declaration. may_alias should not make a
difference here because no access is possible through the incomplete struct.
Bug 61834 may be related.
struct sockaddr;
struct sockaddr *f();
struct __attribute__((may_alias)) sockaddr {};
struct sockaddr *f()
{
return nullptr;
}
results in:
t.cc: In function ‘sockaddr* f()’:
t.cc:5:18: error: ambiguating new declaration of ‘sockaddr* f()’
struct sockaddr *f()
^
t.cc:2:18: note: old declaration ‘sockaddr* f()’
struct sockaddr *f();
^
More information about the Gcc-bugs
mailing list