Bug 3159

Summary: UIPMC_Transport.cpp violates C++ ODR
Product: TAO Reporter: J.T. Conklin <jtc>
Component: PortableGroupAssignee: DOC Center Support List (internal) <tao-support>
Status: NEW ---    
Severity: normal CC: gbr
Priority: P3    
Version: 1.6.1   
Hardware: x86   
OS: Solaris   
Bug Depends on:    
Bug Blocks: 3160    

Description J.T. Conklin 2007-11-30 23:09:45 CST
With a platform_macros.GNU like:
  include ${ACE_ROOT}/include/makeinclude/platform_sunos5_sunc++.GNU

And with a config.h like:
  #include "ace/config-sunos5.10.h"
  #undef ACE_TEMPLATES_REQUIRE_SOURCE

Everything that links against the PortableGroup library fails to build.  According to:  

  http://docs.sun.com/app/docs/doc/819-5267/6n7c46dq3?a=view

(scroll down to section 6.7.6) this is because the global static variable miop_magic[] violates the C++ One Definition Rule.

To fix, miop_magic needs to be made to be made a template class static member variable, or a global defined in another file.
Comment 1 J.T. Conklin 2008-04-28 08:07:26 CDT
Sun has reorganized their documentation, and the link in Comment #1 no longer works.

Rather than chase links, I've excerpted the relevant section:

6.7.6 Referencing Static Variables and Static Functions

Within a template definition, the compiler does not support referencing an object or function that is declared static at global scope or in a namespace. If multiple instances are generated, the One-Definition Rule (C++ standard section 3.2) is violated, because each instance refers to a different object. The usual failure indication is missing symbols at link time.

If you want a single object to be shared by all template instantiations, then make the object a nonstatic member of a named namespace. If you want a different object for each instantiation of a template class, then make the object a static member of the template class. If you want a different object for each instantiation of a template function, then make the object local to the function.