[Bug c++/108013] New: `extern "C" int t = 1;` warns about being declared as extern and initialized

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 7 19:35:44 GMT 2022


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

            Bug ID: 108013
           Summary: `extern "C" int t = 1;` warns about being declared as
                    extern and initialized
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

I don't think we should warn about this case:
```
extern "C" int h = 1; 
```

We should warn for:
```
extern int h = 1; 
```
Though.

We already don't warn for:
```
extern "C" { int h = 1; }
```
Which is a small workaround but I don't think it is needed though.

Forwarded from bug 45977 comment #8 .


More information about the Gcc-bugs mailing list