While for most other types the warning does, as expected, not occur, the following construct causes it. Since the warning cannot be suppressed this especially causes problems in -Werror contexts. Note additionally that despite the warning that object is placed into .rodata (which indicates that the compiler did not lose the 'const' qualifier, as could be assumed by inspecting the check made in grokdeclarator(), which obviously suggests the qualifier is missing). Not also that omitting the extern specifier and turning on optimization leads to the symbol being eliminated if otherwise unreferenced (as expected, but considered another proof of the const qualifier being honored in every other respect). extern void(*const ptr)() = 0;
Confirmed.
Hello, I have sent a patch to the list at http://gcc.gnu.org/ml/gcc-patches/2008-07/msg00160.html. Hopefully that patch should fix this issue.
Subject: Bug 13101 Author: dodji Date: Fri Jul 11 18:12:37 2008 New Revision: 137723 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137723 Log: 2008-07-11 Dodji Seketeli <dseketel@redhat.com> PR c++/13101 * decl.c (grokdeclarator): Warn about initializing variables of storage class 'extern' only after the type of the declarator has been properly computed. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.old-deja/g++.jason/crash11.C
A fix for this bug has been committed to trunk in changeset r137723.