<cut>
>> A one definition rule violation is undefined behavior, no diagnostic
>> required. If a compiler/linker manages to detect it, consider it just
>> as an extra bonus. However the standard does not require a
>> diagnostic.
>
> This is an odd one to me. This seems like a place where a warning
> should be highly advised.
I don't think anyone disputes that. The trouble is that it is hard in
general, so it is left up to implementations to do the best they can.
For example, in one file:
#include <iostream>
struct data { int i; };
void inc(data &d);
int main()
{
data d = { 42 };
inc(d);
std::cout << d.i << "\n";
}
and in another:
struct data { float i; };
void inc(data &d) { d.i += 1; }
C and C++ have always shied away from requireing disgnostics for
conditions that can only be detected at link time.
> Heck, even a warning shall be emitted to properly inform the user
> seems okay with me.
The problem is that many implementations would struggle to get that to
work in every case. In fact, with templates, it might even be
uncomputable. (I'd have to think on that some more.)
--
Ben.