From 363152281907304070
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,cabfc5c4a464a339
X-Google-Attributes: gidf78e5,public
From: maxtal@Physics.usyd.edu.au (John Max Skaller)
Subject: Re: Statics and in-lines
Date: 1995/04/24
Message-ID: <D7Iv3E.Fqz@ucc.su.OZ.AU>#1/1
X-Deja-AN: 101612006
sender: news@ucc.su.OZ.AU
references: <3nb5vm$4au@cronkite.seas.gwu.edu>
organization: School of Physics, University of Sydney, Australia
newsgroups: comp.std.c++

In article <3nb5vm$4au@cronkite.seas.gwu.edu>,
John Carson <carson@gwis2.circ.gwu.edu> wrote:
>I suspect this has been discussed before but I believe it is not valid to 
>define an in-line function that contains a static.  Am I correct and for 
>purposes of learning, where would one find the answer in the ARM or draft 
>standard?

	It is valid to have local static variables in any function.

	If the function is inline or inclass, then:

	1) If the function has internal linkage then each translation
	unit has a distinct function and the local statics are distinct

	2) If the function has external linkage then there is only
	one function in any translation unit and only one static
	variable.

FYI: these rules are not in the ARM. A new rule you should know
about is that ALL non-local classes effectively have external linkage
and ALL member functions of such classes also (effectively) have external
linkage.

That is, effectively linkage is "inherited" by all
nested entities. This is NOT true for inheritance by the way,
in fact the reverse is true: a class derived from a class
with external linkage can have internal linkage BUT a class
derived from a class with internal linkage must have internal
linkage. (This can happen only if the derived class is local
to a function)

It isn't clear the WP correctly states these rules yet.

--
        JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
	Maxtal Pty Ltd,		    
        81A Glebe Point Rd, GLEBE   Mem: SA IT/9/22,SC22/WG21 
        NSW 2037, AUSTRALIA	    Phone: 61-2-566-2189



