freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Still more questions on GCC


From: Mark Mitchell
Subject: Re: Still more questions on GCC
Date: Mon, 29 Oct 2001 13:35:20 -0800

Does GCC work in some different manner so that templates get compiled
even if they are not referenced.  I don't know if I am even making sense
here but I am worried that I may be trying to compile code in
TecFramework that has never been compiled by our other compilers and thus
may be buggy.  Is that possible?

Yes.  Many compilers, for example, will allow:

 template <class T>
 void f() {
   if
 }

as long as "f" is not compiled.  The standard requires a diagnostic for
this code, and GCC will issue the error.  There are many more complex
examples of a roughly similar nature; for example, many compilers will
not complain about:

 template <class T>
 void f() { int i = "abc"; }

but that is invalid according to the standard as well.

The exact rules are complex (they involve the notion of "dependent
types") but basically the code must be fairly reasonable, even if
it is not instantiated.

Of course, you may also be running into bugs in G++.

--
Mark Mitchell                address@hidden
CodeSourcery, LLC            http://www.codesourcery.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]