This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fobey-inline (was Re: gcc and inlining)


On Tuesday, 18 March 2003 18:27, you wrote:
> Ross Smith <r-smith at ihug dot co dot nz> writes:
> | On Tuesday, 18 March 2003 07:22, you wrote:
> | > On Tue, Mar 18, 2003 at 07:18:30AM +1200, Ross Smith wrote:
> | > > The vast majority of inline functions in modern C++ are
> | > > templates. Templates _have_ to be inline, either defined inside
> | > > a class definition or explicitly marked inline if they're
> | > > defined out of line or aren't class members. There's no
> | > > portable way to use templates without marking them inline.
> | >
> | > This is not correct.  The template has to appear in the header;
> | > it need not be declared inline.
> |
> | Yes it does.
>
> No, it does not.  Check out the C++ definition.

Could you be more specific please? Reading 14.5.5 (function templates) 
and 14.7.1 (implicit instantiation) turns up nothing relevant, as far 
as I can see. 3.2 (one definition rule) para 3 says "Every program 
shall contain exactly one definition of every non-inline function or 
object that is used in that program", which seems pretty clear to me.

> | A function defined in a header but not inline will trigger
> | ODR violations as soon as more than one module includes it.
>
> Templates have special status.  See the chapter on implicit
> instantiations. Have a look at the "Template instantiation" in the
> GCC manual.

I'm aware of the way this works in GCC. This is explicitly documented as 
a GCC _extension_ to C++ (albeit one also implemented by several other 
compilers). I didn't say there was no way to do it, I said there was no 
_portable_ way to do it.

-- 
Ross Smith ......... r-smith at ihug dot co dot nz ......... Auckland, New Zealand

Eagles may soar, but weasels never get sucked into a land war in Asia.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]