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++/85601] New: [8 Regression] anonymous struct & union namespace conflict in extern C block


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85601

            Bug ID: 85601
           Summary: [8 Regression] anonymous struct & union namespace
                    conflict in extern C block
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andres at anarazel dot de
  Target Milestone: ---

Hi,

When compiling with g++ anonymous structs / unions inside C functions conflict
based on their variable name.  That wasn't previously the case and doesn't seem
to make much sense.

Ex.:

extern "C"
{
  static inline void funca(void)
  {
      union
      {
        int a;
      } myunion;

      (void) myunion;
  }

  static inline void funcb(void)
  {
      union
      {
        int a;
      } myunion;

      (void) myunion;
  }
}

andres@alap4:~/src/postgresql$ /usr/lib/gcc-snapshot/bin/g++ --version
g++ (Debian 20180425-1) 9.0.0 20180425 (experimental) [trunk revision 259645]
..

andres@alap4:~/src/postgresql$ /usr/lib/gcc-snapshot/bin/g++ -c -o /tmp/frak.o
/tmp/frak.cc
/tmp/frak.cc: In function 'void funcb()':
/tmp/frak.cc:18:9: warning: conflicting C language linkage declaration
'funcb()::<unnamed union> myunion'
       } myunion;
         ^~~~~~~
/tmp/frak.cc:8:9: note: previous declaration 'funca()::<unnamed union> myunion'
       } myunion;
         ^~~~~~~
If I rename one of the *variables* in the *independent* functions the error
vanishes.

This currently triggers inside PostgreSQL's master branch (which now uses C++
for an optional module).

Regards,

Andres Freund

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