Bug 13101 - incorrect warning on initialized extern const function pointer
Summary: incorrect warning on initialized extern const function pointer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: 4.4.0
Assignee: Dodji Seketeli
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2003-11-18 10:45 UTC by jbeulich
Modified: 2008-07-11 18:32 UTC (History)
1 user (show)

See Also:
Host: i686-pc-gnu-linux
Target: i686-pc-gnu-linux
Build: i686-pc-gnu-linux
Known to work:
Known to fail: 3.0.4 3.3.1 3.4.0 4.0.0
Last reconfirmed: 2008-07-10 14:30:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jbeulich 2003-11-18 10:45:17 UTC
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;
Comment 1 Andrew Pinski 2004-04-27 18:34:31 UTC
Confirmed.
Comment 2 Dodji Seketeli 2008-07-02 22:19:12 UTC
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.
Comment 3 Dodji Seketeli 2008-07-11 18:13:32 UTC
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

Comment 4 Dodji Seketeli 2008-07-11 18:32:07 UTC
A fix for this bug has been committed to trunk in changeset r137723.