[Bug c/45977] "warning: 'i' initialized and declared 'extern'" could use a separate warning flag controlling it

2022-12-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977

--- Comment #9 from Andrew Pinski  ---
(In reply to Jörn Heusipp from comment #8)
> I am seeing the same warning, however in C++, when trying to set DJGPP's CRT
> startup flags (see ):

I filed PR 108013 for that case since it is a different issue all together
really.

[Bug c/45977] "warning: 'i' initialized and declared 'extern'" could use a separate warning flag controlling it

2022-03-23 Thread manx-bugzilla at problemloesungsmaschine dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977

Jörn Heusipp  changed:

   What|Removed |Added

 CC||manx-bugzilla@problemloesun
   ||gsmaschine.de

--- Comment #8 from Jörn Heusipp  ---
I am seeing the same warning, however in C++, when trying to set DJGPP's CRT
startup flags (see ):

```
manx@appendix:~/tmp$ cat djgpp-main.cpp
#include 
extern "C" int _crt0_startup_flags = 0 | _CRT0_FLAG_LOCK_MEMORY;
int main(int argc, char * argv[]) {
_crt0_startup_flags &= ~_CRT0_FLAG_LOCK_MEMORY;
static_cast(argc);
static_cast(argv);
return 0;
}
manx@appendix:~/tmp$ i386-pc-msdosdjgpp-g++ -c -std=gnu++17 -O2 -Wall -Wextra
-Wpedantic djgpp-main.cpp
djgpp-main.cpp:2:16: warning: '_crt0_startup_flags' initialized and declared
'extern'
2 | extern "C" int _crt0_startup_flags = 0 | _CRT0_FLAG_LOCK_MEMORY;
  |^~~
manx@appendix:~/tmp$
```

minimal test case:
```
manx@appendix:~/tmp$ cat warn.cpp
extern "C" {
extern int foo;
}
extern "C" int foo = 23;
manx@appendix:~/tmp$ g++ -c -std=c++17 -O2 -Wall -Wextra -Wpedantic warn.cpp
warn.cpp:4:16: warning: ‘foo’ initialized and declared ‘extern’
4 | extern "C" int foo = 23;
  |^~~
manx@appendix:~/tmp$
```

also happens with no -W flags:
```
manx@appendix:~/tmp$ g++ -c -std=c++17 -O2 warn.cpp
warn.cpp:4:16: warning: ‘foo’ initialized and declared ‘extern’
4 | extern "C" int foo = 23;
  |^~~
```

However, I am not seeing the warning in C code:
```
manx@appendix:~/tmp$ cat warn.c
extern int foo;
int foo = 23;
manx@appendix:~/tmp$ gcc -c -std=c17 -O2 -Wall -Wextra -Wpedantic warn.c
manx@appendix:~/tmp$
```

I would really appreciate an option to disable this warning in C++.

I am not 100% sure if my issue is really identical, but it certainly looks
related.

Also, as the original issue was about C, do you want me to report a separate
issue for C++?

GCC versions:

manx@appendix:~/tmp$ gcc --version
gcc (Debian 11.2.0-18) 11.2.0

manx@appendix:~/tmp$ i386-pc-msdosdjgpp-gcc --version
i386-pc-msdosdjgpp-gcc (GCC) 10.3.0

[Bug c/45977] "warning: 'i' initialized and declared 'extern'" could use a separate warning flag controlling it

2019-09-16 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977

--- Comment #7 from Eric Gallager  ---
This bug provoked this StackOverflow question:
https://stackoverflow.com/questions/57957168/how-do-i-disable-a-gcc-warning-which-has-no-command-line-switch

[Bug c/45977] "warning: 'i' initialized and declared 'extern'" could use a separate warning flag controlling it

2017-07-25 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977

Eric Gallager  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-07-25
 Ever confirmed|0   |1

--- Comment #6 from Eric Gallager  ---
(In reply to Eric Gallager from comment #5)
> Confirming on the basis that a separate warning flag here would be nice

Oops I retitled it but forgot to actually confirm it like I said I was doing
(sorry; hopefully I've got it this time)

[Bug c/45977] "warning: 'i' initialized and declared 'extern'" could use a separate warning flag controlling it

2017-07-25 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45977

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org
Summary|"warning: 'i' initialized   |"warning: 'i' initialized
   |and declared 'extern'" is   |and declared 'extern'"
   |spurious|could use a separate
   ||warning flag controlling it
   Severity|normal  |enhancement

--- Comment #5 from Eric Gallager  ---
Confirming on the basis that a separate warning flag here would be nice