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++/14769] New: Block extern incorrectly resolved to file-scope internal linkage object


In the following it is clear from the example in the C++ Standard 3.5.#6 that 
the block extern declaration refers to a separate object, i.e. that there is an 
internal-linkage i and an external-linkage i in the same TU.  As in C a block 
extern that does not 'see' an internal-linkage declaration (as in this case 
where hidden by the formal) gets external linkage; C 6.2.2#7 says that having 
internal and external linkage for the same name is UB but no such prohibition 
applies in C++.  G++ incorrectly resolves the block extern to the file-scope 
object (which in C++ is internal linkage) but should instead generate an 
external reference for the i object that is declared in the block extern.

#include <stdio.h>

const int i = 123;
int main(int i, char **) {
  {
    extern int i;
    printf("i = %u\n", i);
  }
  return 0;
}

-- 
           Summary: Block extern incorrectly resolved to file-scope internal
                    linkage object
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: algrant at acm dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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