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/49975] New: warn on malformed __attribute((...))__


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

           Summary: warn on malformed __attribute((...))__
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ext@sidvind.com


Recently I ran into a linker error "multiple definition of `__'" which was
caused by struct with a IMO malformed attribute. Consider the following struct
in a header:

struct foo {
  int bar;
} __attribute((unused))__;

At a first glance it seems like there is nothing wrong here but since the "__"
is placed after "))" it happily creates an uninitialized global called "__".
This global will then be created in multiple files and when linking will lead
to the "multiple definition" error.

First of all, I think whitespace should be required after "))" to make it
really clear what is going happen. Secondly I don't think "__attribute(("
should work at all since the documentation states that "__attribute__" is the
keyword.

I've tried this with many different versions of gcc (including older versions
like gcc-3.3) and they all have this behaviour.


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