From 958591696174230542
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,cabfc5c4a464a339
X-Google-Attributes: gidf78e5,public
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: Statics and in-lines
Date: 1995/04/27
Message-ID: <9511718.7740@mulga.cs.mu.OZ.AU>#1/1
X-Deja-AN: 101611983
sender: news@cs.mu.OZ.AU (CS-Usenet)
references: <3nb5vm$4au@cronkite.seas.gwu.edu>
organization: Computer Science, University of Melbourne, Australia
newsgroups: comp.std.c++

carson@gwis2.circ.gwu.edu (John Carson) writes:

>I suspect this has been discussed before

Yes, at least twice before...

>but I believe it is not valid to 
>define an in-line function that contains a static. 

It is valid, but it may not do what you expect, because
inline functions have static linkage (unless otherwise specified),
and if the "same" static function is defined in more than one
translation unit, they get separate copies any the static variables.

If the inline function has external linkage (e.g. if it is a member
function), then in theory it should be fine.  In practice some 
(low-quality) compilers may fail to inline it, and it is possible
that some buggy compilers might even generate incorrect code for it.

>Am I correct and for 
>purposes of learning, where would one find the answer in the ARM or draft 
>standard?

Check WP 3.5 (Program and linkage).

-- 
Fergus Henderson            | Tell you what: go write a 100x100 matrix multiply
fjh@cs.mu.oz.au             | of integers in both languages and then let's talk
http://www.cs.mu.oz.au/~fjh | about speed, ok? - Tom Christiansen.



