Bug 3159 - UIPMC_Transport.cpp violates C++ ODR
Summary: UIPMC_Transport.cpp violates C++ ODR
Status: NEW
Alias: None
Product: TAO
Classification: Unclassified
Component: PortableGroup (show other bugs)
Version: 1.6.1
Hardware: x86 Solaris
: P3 normal
Assignee: DOC Center Support List (internal)
URL:
Depends on:
Blocks: 3160
  Show dependency tree
 
Reported: 2007-11-30 23:09 CST by J.T. Conklin
Modified: 2009-09-10 06:53 CDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.