[Boost-bugs] [Boost C++ Libraries] #11112: CS identifier causes compilation failure in geometry/test/strategies/distance_default_result.cpp

Subject: [Boost-bugs] [Boost C++ Libraries] #11112: CS identifier causes compilation failure in geometry/test/strategies/distance_default_result.cpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-03-12 23:00:31


#11112: CS identifier causes compilation failure in
geometry/test/strategies/distance_default_result.cpp
------------------------------+---------------------------
 Reporter: Sergey.Sprogis@… | Owner: barendgehrels
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------
 1. Description of the failure.

  geometry/test/strategies/distance_default_result.cpp fails with Oracle
 Studio 12.4 C++ compiler on Solaris producing error message similar to
 this:

     "CC" -library=stlport4 -xO4 -mt -erroff=%none -KPIC
 -DBOOST_ALL_NO_LIB=1 -DNDEBUG -I"." -I"../../.."
 -I"../../../boost/geometry/extensions/contrib/ttmath" -c -o
 "../../../bin.v2/libs/geometry/test/strategies/distance_default_result.test/sun/release
 /stdlib-sun-stlport/threading-multi/distance_default_result.o"
 "strategies/distance_default_result.cpp"

 "strategies/distance_default_result.cpp", line 183: Error: "," expected
 instead of "15".

    2. Cause of the failure.

 The code of this test is perfectly fine from language 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 presence of #include <sys/regset.h> system header, direct or
 indirectly attached through other system headers from /usr/include
 directory.

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

 Here is an example of such 2 lines code:

 #include <sys/regset.h>

 template <unsigned D, typename CS> inline void test_segment_all() {};

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

 #define CS 15

 #define DS 3

 #define ES 2

 and when compiler preprocesses this header, after that it automatically
 replaces user identifiers which accidentally have the same names with
 those numbers shown above.

 So, in the original 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, and when finally compiler preprocesses
 code from the test shown below:

 template <std::size_t D, typename CS> // Line 183

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

    3. Possible Solution.

 To replace CS identifier inside
 geometry/test/strategies/distance_default_result.cpp with any other
 similar name, like for example C_S.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11112>
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