🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2426

Re: ??? static locals in inline functions ???

#2426
From: Jason Merrill
Date: Sat, 04 Nov 1995 09:36
32 lines
1674 bytes
>>>>> Kaelin Colclasure <kaelin@bridge.com> writes:

> What behavior does the draft standard condone for the following
> scenario:

> 1) In a header file, an inline function is defined to contain a local
> static, like so:

> 2) Two seperate modules include this header file, call them A and B.
> A "initializes" foo():

> 3) B calls foo(), dereferences the pointer returned and prints its
> value:

> Some data points:

> MSVC++:	*foo() = 1
> G++:	*foo() = 0
> Sun C++:*foo() = 0

> My intuition is that MSVC++ is doing the "right" thing (gasp), and what
> "should" be the standard thing.

G++ and Sun conform to the current working paper for this example.  If
foo had been explicitly declared 'extern inline', or if it were a member
function, MS would be correct.

Jason
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <u9g2g5xbre.fsf@yorick.cygnus.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <KAELIN.95Nov2201050@binki.bridge.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 04 Nov 95 09:36:09 GMT
Approved: fjh@cs.mu.oz.au
From: jason@cygnus.com (Jason Merrill)
Newsgroups: comp.std.c++
Subject: Re: ??? static locals in inline functions ???
X-Original-Date: 03 Nov 1995 20:08:21 -0800
Organization: Cygnus Support, Mountain View, CA
Message-ID: <u9g2g5xbre.fsf@yorick.cygnus.com>
References: <KAELIN.95Nov2201050@binki.bridge.com>
In-Reply-To: kaelin@bridge.com's message of 03 Nov 95 03:29:32 GMT
X-Newsreader: Gnus v5.0
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMJs0EuEDnX0m9pzZAQGvvgF+NRazFjTxS9OQ0J3EwxGRkqpY/0kVRdVN
 IEGhZMjy114TEii5LoW4v7zwgUp7wE17
 =5M4B