Christopher Benson-Manica wrote:
> Victor Bazarov <> wrote:
>
>> First of all, they are declared 'inline', so the compiler has to make
>> sure it "merges" all definitions of it into one (if it decides to
>> create an "out-of-line" definition, that is). The compiler is
>> unable (or maybe unwilling) to check that your functions have
>> different bodies. It is
>> a violation of the One Definition Rule, but sometimes violations like
>> this are subtle and you yourself need to watch for them.
>
> I admit I didn't catch the subtleties involved with the use of
> "inline". OP's code is still wrong without inline, though, correct?
Theoretically. The bodies of the two functions are different. That goes
against the ODR. I don't know of any compiler that would enforce that,
however.
> I suppose the use of "inline" is what led to the linker being quiet;
> in my experience, this situation is reported by the linker assuming it
> is invoked with reasonable arguments.
Then your linker if more advanced than the ones I've seen.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
|