static data in inline methods

Mitch Miers mmiers@intellinet-tech.com
Thu Jan 7 17:47:00 GMT 1999


Dunno if anyone's reported this...  The code's not pretty nor
efficient, but I *think* it should be legal.

kanga.internal.net> g++ -v
Reading specs from
/freeware/lib/gcc-lib/alphaev56-dec-osf4.0d/egcs-2.91.60/specs
gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)

kanga.internal.net> uname -a
OSF1 kanga.internal.net V4.0 878 alpha

Here's the code:
t.h:---------------- <snip> ------------------------
#include <vector>
 
typedef unsigned char byte;
 
class Config
{
public:
    Config() {}
    ~Config() {}
 
    vector<byte>& GetOrigTrig()
    {
        static byte defOrig[4] = { 0xFF, 0xFF, 0xFF, 0xFF };
        static vector<byte> origs(defOrig);
 
        return origs;
    }
};
t.h:---------------- <snip> ------------------------

t.cpp:---------------- <snip> ------------------------
#include <vector>
 
#include "t.h"
t.cpp:---------------- <snip> ------------------------

Compile time gives:

kanga.internal.net> g++ -v --save-temps t.cpp
Reading specs from
/freeware/lib/gcc-lib/alphaev56-dec-osf4.0d/egcs-2.91.60/specs
gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
 /freeware/lib/gcc-lib/alphaev56-dec-osf4.0d/egcs-2.91.60/cpp -lang-c++
-v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91
-Dunix -D__osf__ -D_LONGLONG -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__unix__
-D__osf__ -D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix
-D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -D__EXCEPTIONS
-D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C -Acpu(alpha)
-Amachine(alpha) -D__alpha -D__alpha__ -D__alpha_ev5__ -Acpu(ev5)
-D__alpha_bwx__ -Acpu(bwx) t.cpp t.ii
GNU CPP version egcs-2.91.60 19981201 (egcs-1.1.1 release)
#include "..." search starts here:
#include <...> search starts here:
 /freeware/include/g++
 /usr/local/include
 /freeware/alphaev56-dec-osf4.0d/include
 /freeware/lib/gcc-lib/alphaev56-dec-osf4.0d/egcs-2.91.60/include
 /usr/include
End of search list.
 /freeware/lib/gcc-lib/alphaev56-dec-osf4.0d/egcs-2.91.60/cc1plus t.ii
-quiet -dumpbase t.cc -version -o t.s
GNU C++ version egcs-2.91.60 19981201 (egcs-1.1.1 release)
(alphaev56-dec-osf4.0d) compiled by GNU C version egcs-2.91.60 19981201
(egcs-1.1.1 release).
t.h: In method `class vector<unsigned
char,__default_alloc_template<false,0> > & Config::GetOrigTrig()':
In file included from t.cpp:3:
t.h:13: warning: sorry: semantics of inline function static data
`unsigned char defOrig[4]' are wrong (you'll wind up with multiple
copies)
t.h:13: Internal compiler error.
t.h:13: Please submit a full bug report to `egcs-bugs@cygnus.com'.
t.h:13: See <URL: http://egcs.cygnus.com/faq.html#bugreport > for details.

Hope this helps...

Mitch

------------------------------
Mitch Miers <miers@packet.net>
Law of Programming #41: The first 90% of a project takes 90% of the
time; the
last 10% takes the other 90% of the time.
Law of Programming #42: A pat on the back is only a few centimeters from
a kick
in the butt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.ii.gz
Type: application/x-gzip
Size: 19627 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/19990107/b2b65c67/attachment.bin>


More information about the Gcc-bugs mailing list