From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2BF7B385E004; Wed, 23 Mar 2022 12:15:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BF7B385E004 From: "manx-bugzilla at problemloesungsmaschine dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/45977] "warning: 'i' initialized and declared 'extern'" could use a separate warning flag controlling it Date: Wed, 23 Mar 2022 12:15:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: diagnostic, easyhack X-Bugzilla-Severity: enhancement X-Bugzilla-Who: manx-bugzilla at problemloesungsmaschine dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2022 12:15:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D45977 J=C3=B6rn Heusipp changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manx-bugzilla@problemloesun | |gsmaschine.de --- Comment #8 from J=C3=B6rn 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 =3D 0 | _CRT0_FLAG_LOCK_MEMORY; int main(int argc, char * argv[]) { _crt0_startup_flags &=3D ~_CRT0_FLAG_LOCK_MEMORY; static_cast(argc); static_cast(argv); return 0; } manx@appendix:~/tmp$ i386-pc-msdosdjgpp-g++ -c -std=3Dgnu++17 -O2 -Wall -We= xtra -Wpedantic djgpp-main.cpp djgpp-main.cpp:2:16: warning: '_crt0_startup_flags' initialized and declared 'extern' 2 | extern "C" int _crt0_startup_flags =3D 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 =3D 23; manx@appendix:~/tmp$ g++ -c -std=3Dc++17 -O2 -Wall -Wextra -Wpedantic warn.= cpp warn.cpp:4:16: warning: =E2=80=98foo=E2=80=99 initialized and declared =E2= =80=98extern=E2=80=99 4 | extern "C" int foo =3D 23; | ^~~ manx@appendix:~/tmp$ ``` also happens with no -W flags: ``` manx@appendix:~/tmp$ g++ -c -std=3Dc++17 -O2 warn.cpp warn.cpp:4:16: warning: =E2=80=98foo=E2=80=99 initialized and declared =E2= =80=98extern=E2=80=99 4 | extern "C" int foo =3D 23; | ^~~ ``` However, I am not seeing the warning in C code: ``` manx@appendix:~/tmp$ cat warn.c extern int foo; int foo =3D 23; manx@appendix:~/tmp$ gcc -c -std=3Dc17 -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=