🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #791

linkage specification and const objects

#791
From: John Hassey
Date: Thu, 13 Aug 1992 17:41
39 lines
1468 bytes
    I've encountered a difference between cfront 2.1 and g++ 2.2, and
    can't find anything in the ARM that explains who is right.

    Consider:

	extern "C" const int a;

    Cfront 2.1 will compile this into:

	extern int a; (or extern const int a; with +a1)

    g++ 2.2 gives: "uninitialized const `a'"  (g++ 2.1 does not)

    The code in g++ cites 7.1.6 in the ARM. "Unless explicitly
    declared extern, a const object does not have external linkage
    and must be initialized."

    So g++ wants something like this to be happy:

    	extern "C" extern const int a;

    But cfront doesn't like that at all.

    It looks to me like g++ is wrong on this one.

    extern "C" const int a; 

    is a declaration not a definition (7.4). But

    extern "C" {
    const int a;
    };

    Is a definition, so the error is justified on this, and  cfront 2.1
    does give an error.

    Comments ?

    john.  (hassey@dg-rtp.dg.com)
Technical Details
Message-ID: <1992Aug13.174157.6794@dg-rtp.dg.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!matrix.rtp.dg.com!hassey

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!matrix.rtp.dg.com!hassey
From: hassey@matrix.rtp.dg.com (John Hassey)
Subject: linkage specification and const objects
Message-ID: <1992Aug13.174157.6794@dg-rtp.dg.com>
Followup-To: comp.lang.c++
Sender: gnulists@ai.mit.edu
Organization: Data General Corporation, RTP, NC.
Distribution: gnu
Date: Thu, 13 Aug 1992 17:41:57 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 41