home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!caen!sdd.hp.com!apollo.hp.com!netnews
- From: vinoski@apollo.hp.com (Stephen Vinoski)
- Subject: Re: template static data members
- Sender: usenet@apollo.hp.com (Usenet News)
- Message-ID: <Bt8K2o.Azy@apollo.hp.com>
- Date: Wed, 19 Aug 1992 14:54:23 GMT
- References: <Bt5FDH.DFK@apollo.hp.com> <4086@seti.UUCP>
- Nntp-Posting-Host: zep_e.ch.apollo.hp.com
- Organization: Hewlett-Packard Corporation, Chelmsford, MA
- Lines: 42
-
- In article <4086@seti.UUCP> Daniel R. Edelson <edelson@sor.inria.fr> writes:
- >In article <Bt5FDH.DFK@apollo.hp.com>, vinoski@apollo.hp.com (Stephen Vinoski) writes:
- >|>
- >|> template<class T> Simple LessSimple<T>::s;
- >|>
- ><problem and explanation omitted>
- >|>
- >|> Unfortunately, in the example case
- >|> above, ``s'' cannot be explicitly initialized, and the problem cannot
- >|> be solved without changing the declaration of Simple so such
- >|> initialization is allowed (if possible).
- >|>
- >|> -steve
- >
- >Can't it be initialized with a temporary which the compiler
- >may or may not optimize away?
- >
- > template<class T> Simple LessSimple<T>::s = Simple();
- >
- >(Not that this makes the bug much less annoying.)
-
- Yes, this works. I had tried this a couple months ago when I first
- ran into this problem, but I must have done something wrong because it
- didn't work. :-(
-
- Regardless of my error, the real problem underlying all of this is
- that the compiler cannot tell a legal program containing an
- uninitialized definition for each static data member from an illegal
- program containing only declarations, no definitions, for each static
- data member, since in both cases a bss symbol is created. It never
- used to matter until templates and automatic instantiation came along.
-
- Thanks for making me go back and try this again, Dan, and also thanks
- for embarrassing me in public. :-) You should already know that I am
- perfectly capable of doing that without anyone's help. :-)
-
- -steve
-
- --
- Steve Vinoski (508)436-5904 vinoski@apollo.hp.com
- Distributed Object Computing Program
- Hewlett-Packard, Chelmsford, MA 01824 These are my opinions.
-