1 Reply Latest reply on Jul 22, 2010 10:16 PM by mayaknife

    'icpc -g -fvisibility-inlines-hidden' bug

    mayaknife

      There appears to be a bug in how the Intel compiler handles the visibility of inline methods of fully specialized template classes when '-g' and '-fvisibility-inlines-hidden' are both present: the inline is made visible. This conflicts with g++ which keeps the inline hidden.

       

      This is on OSX. I don't know if the same problem afflicts Linux.

       

      For example, Common.h contains the following template base class and a fully specialized class which derives from it. Both classes have their visibility explicitly set to 'default':

       

      #define EXPORT __attribute__ ((visibility("default")))

      template <class T>
      class EXPORT Base
      {
      public:
          inline void            setRoot( void* root)    { fRoot = root; }
          void*    fRoot;
      };


      class EXPORT Derived : public Base<int>
      {
      public:
          inline void            setRoot( void* root)    { fMyRoot = root; }
          void*    fMyRoot;
      };

      UsesGcc.cpp contains a class which calls Derived::setRoot():

       

      #include "Common.h"

      class UsesGcc
      {
      public:
          virtual void func();
      };


      void UsesGcc::func()
      {
          Derived d;
          d.setRoot(0);
      }

       

      It is compiled using g++ as follows:

       

      g++-4.2 -Wall -c -arch x86_64 -g -fvisibility=hidden -fvisibility-inlines-hidden -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -o UsesGcc.o UsesGcc.cpp

       

      UsesIntel.cpp is identical to UsesGcc.cpp except for the name of the class. It is compiled using icpc as follows:

       

      icpc -std=c++0x -gcc-version=420 -gxx-name=/usr/bin/g++-4.2 -cxxlib -Wall -c -arch x86_64 -g -fvisibility=hidden -fvisibility-inlines-hidden -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -o UsesIntel.o UsesIntel.cpp

       

      The two files are linked into a shared object using icpc:

       

      icpc -no-ipo -std=c++0x -g -gcc-version=420 -gxx-name=/usr/bin/g++-4.2 -cxxlib -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6 -arch x86_64 -headerpad_max_install_names -m64 -single_module -dynamiclib -o visibility.dylib UsesIntel.o UsesGcc.o

       

      which produces the following warning:

       

      ld: warning: __ZN7Derived7setRootEPv has different visibility (hidden) in UsesGcc.o and (default) in UsesIntel.o

       

      If I remove the '-g' or the '-fvisibility-inlines-hidden' from both compiles then the warning goes away.

       

      In the full product that I'm working on this bug results in hundreds of bogus warnings which make it difficult to find real errors in symbol visibility. If anyone can provide a workaround, I would appreciate it.