[Boost-bugs] [Boost C++ Libraries] #11110: ES identifier causes compilation failure in polygon/transform.hpp becase of Solaris bug

Subject: [Boost-bugs] [Boost C++ Libraries] #11110: ES identifier causes compilation failure in polygon/transform.hpp becase of Solaris bug
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-03-12 05:10:47


#11110: ES identifier causes compilation failure in polygon/transform.hpp becase of
Solaris bug
------------------------------+----------------------
 Reporter: Sergey.Sprogis@… | Owner: ljsimons
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: polygon
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------
 1. Description of the failure.

 Several tests inside libs/geometry/test directory fail with Oracle Studio
 12.4 C++ compiler on Solaris producing error message similar to this:

 CC -c -library=stlport4 -erroff=%none -KPIC -DBOOST_ALL_NO_LIB=1 -DNDEBUG
 -I. -I../../.. -I../../../boost/geometry/extensions/contrib/ttmath
 geometries/boost_polygon.cpp

 "../../../boost/polygon/transform.hpp", line 49: Error: Identifier
 expected instead of "2".

 2. Cause of the failure.

 transform.hpp header is perfectly fine from user standpoint, and the
 failure is related to long-existing bug
 in all later Solaris versions. Basically, compilation of any C or C++ code
 will fail on Solaris if it will satisfy two
 conditions:

  - The presense of #include <sys/regset.h> system header, direct or
 indirectly attached through other system headers from /usr/include
 directory.

  - The presence of identifires which accidentally coincide with X86
 register names, like CS, DS, ES, ...

 Here is an example of such 2 lines code:

 #include <sys/regset.h>

 void foo() { enum E { ES=2 }; }

 its compilation will produce error message similar to the one shown above.
 The failure occur because that sys/regset.h has the following macros:

 #define CS 15

 #define DS 3

 #define ES 2

 and when compiler preprocesses sys/regset.h after that it automatically
 replaces user identifiers which accidentally have the same names with
 those numbers shown above.

 So, in the original libs/geometry/test/geometries/boost_polygon.cpp test
 <sys/regset.h> has been attached
 indirectly through long chain of system headers defined inside STL library
 with the usage of
 -library=stlport4 option. So, when finally compiler preprocesses code from
 boost/polygon/transform.hpp
 shown below:

   enum ATR {

       ES = 2, EAST_SOUTH = 2, FLIP_Y = 2, // Line 49

 it wrongly replaces ES with '2' assuming that it comes from macro defined
 inside sys/regset.h

 3. Possible Solution.

 To replace ES identifier inside boost/polygon/transform.hpp with any other
 similar name, like for example E_S. And if it's not acceptable for every
 compiler, then please do it just for Oracle studio compiler like this:

 #if definde __SUNPRO_CC

  E_S = 2, EAST_SOUTH = 2, FLIP_Y = 2,

 #else

  ES = 2, EAST_SOUTH = 2, FLIP_Y = 2,

 #endif

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11110>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC