Thanks for the quote, it takes a couple of readings to decrypt what
they intended to say, actually I still didn't quite get what their
*intention* was but according to these rules what mr. Stenbach says is
not strictly incorrect.. as long as the *definition* is inline in every
translation init all's well as far as the standard is concerned.
Quote from the quote (thanks!): "If a function with external
linkage is declared inline in one translation unit, it shall be
declared
inline in all translation units in which it appears; no diagnostic is
required."
The keyword here is *declared*, declared.. that will hold up true
indeed if the same header is included in other translation units (note:
I am not claiming that files or headers exist they are just figment of
implementations imagination ;-) So far so good, the original poster's
hypothesis (?) doesn't invalidate this rule..
Earlier in the same paragraph this is stated:
"4 An inline function shall be defined in every translation unit in
which it
is used and shall have exactly the same definition in every case
(3.2)."
Indeed, if the *definition* is in other translation unit, in this case
I read between the lines that in a different sourcefile (okay, again,
implementation specific detail but that's how I interpreted the
original post, call me incompetent
So far again I don't see any
gross neglegance or violation of the standard in the original post,
just construct which requires every other translation unit to have the
*same* definition, this is rather difficult to enforce unless the same
sourcecode is part of the other translation units being compiled. The
common method to achieve this is to put the inline code in a header
file, often the declaration and definition are the same thing.. or the
definition comes later in the same file, or, separate implementation
file is used, .inl is what I encountered myself now and then (not my
sourcecode heaven's sake, I combine the definition with declaration
more often than not
All in all, I don't seem to see where the actual error is, I only see
where it could possibly be but w/o any actual sourcecode to discuss..
The example you posted is a good case, btw. Side effects, linkage,
undefined behaviour and such aside, one way I can see this could be
implemented without much fuss is that the compiler merely ignores the
inline keyword. It's free to do so at any time of it's liking for code
generation purposes anyhow. The only difficulty is that the standard
itself disagrees (?) with the TC++PL.. I'd say I'd trust the standard
more in this case as that's what all implementations are supposed to be
implementing (?) I'm very likely to be wrong since I am way out of my
league here.. but I got asshole and I got opinions and this is a
discussion group so there! ;-)