[OpenWalnut-Dev] duplicate class names

Christian Heine heine at informatik.uni-leipzig.de
Thu Oct 7 17:13:30 CEST 2010


Hi,

it is true that the compiler cannot check for the ODR violation 
because there is no compilation unit that includes both 
common/WHistogram.h and clusterDisplay/WHistogram.h. But the linker 
when linking clusterDisplay/*.o and libOWcommon.so (among other 
things) into clusterDisplay.so should find that the virtual table 
and some common constructors for WHistogram are defined twice. I 
checked that they are actually exported in each object.

So the linker could actually detect the duplicate symbols before 
runtime.

Christian

On 10/07/10 16:52, Mario Hlawitschka wrote:
> Hi,
>
> the compiler cannot check because the collision happens at runtime when loading the different libraries. It usually checks within the same library and reports errors there.
> It should be the dynamic linker that checks, and they tend to be amazingly lazy... (and highly platform-dependent)
>
> 	Mario
>
> On Oct 7, 2010, at 2:16 AM, Christian Heine wrote:
>
>> Hi,
>>
>> according to the one definition rule of C++, the program is invalid in the presence of two different classes with the same name. The compiler/linker *must* check for it. Why they do not is mysterious.
>>
>> Which class is it btw.?
>>
>> Christian
>>
>> On 10/06/10 19:37, Ralph Schurade wrote:
>>> Hello All,
>>>
>>> today i was hunting down a bug/crash that didn't make sense at all.
>>> In the end i found out it was because someone created a class (in common)
>>> with the same name as one that was already in use in the module in question.
>>> Now the compiler and linker obviously had no problem with that, not even
>>> a warning, but it crashed at runtime.
>>>
>>> So the question here is, how to avoid this? Can we tweak the stylechecker
>>> to look for something like that? Namespaces? Even though we don't like them.
>>>
>>> Opinions?


More information about the OpenWalnut-Dev mailing list