Boost C++ Libraries: Ticket #6158: Compilation error in numeric using gcc 4.6.1 on Solaris/SPARC https://svn.boost.org/trac10/ticket/6158 <p> I am getting the following errors on Solaris 10 (SPARC) using gcc 4.6.1: </p> <p> ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:25:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:13:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:158:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:13:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:170:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:13:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:182:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, unsigned char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:37:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, unsigned char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:194:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, short int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:49:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, short int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:206:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, short unsigned int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:61:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, short unsigned int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:218:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:73:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:230:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, unsigned int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:85:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, unsigned int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:242:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, long long int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:97:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, long long int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:254:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, long long unsigned int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:109:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, long long unsigned int&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:266:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, float&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:121:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, float&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:278:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, double&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:133:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, double&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:290:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;char, long double&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:145:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;char, long double&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:315:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;unsigned char, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:303:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;unsigned char, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:460:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;short int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:448:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;short int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:605:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;short unsigned int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:593:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;short unsigned int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:750:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:738:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:895:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;unsigned int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:883:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;unsigned int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1040:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;long long int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1028:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;long long int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1185:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;long long unsigned int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1173:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;long long unsigned int, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1330:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;float, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1318:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;float, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1475:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;double, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1463:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;double, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1620:12: error: redefinition of 'struct boost::numeric::numeric_cast_traits&lt;long double, char&gt;' ./boost/numeric/conversion/detail/preprocessed/numeric_cast_traits.hpp:1608:12: error: previous definition of 'struct boost::numeric::numeric_cast_traits&lt;long double, char&gt;' </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6158 Trac 1.4.3 ipapadop@… Tue, 29 Nov 2011 19:27:34 GMT attachment set https://svn.boost.org/trac10/ticket/6158 https://svn.boost.org/trac10/ticket/6158 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">cstdint_patch.diff</span> </li> </ul> <p> cstdint.hpp patch for Solaris 10.0/gcc 4.6.1 </p> Ticket tsandnes@… Tue, 20 Dec 2011 13:57:03 GMT <link>https://svn.boost.org/trac10/ticket/6158#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6158#comment:1</guid> <description> <p> I am seeing the same thing on windows 7, mscv100. </p> <p> The error is slightly different: </p> <p> error C2766: explicit specialization; 'boost::numeric::numeric_cast_traits&lt;char,uint64_t&gt;' has already been defined C:\svn\Backend\third_party\win32_vc100\include\boost\numeric\conversion\detail\preprocessed\numeric_cast_traits.hpp 263 </p> <p> Changing from using::int8_t to typedef signed char int8_t; as in the patch for solaris solves the problem here as well. Maybe the patch should be modified to change this for windows7/msvc100 too? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 28 Jan 2012 12:25:32 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/6158#comment:2 https://svn.boost.org/trac10/ticket/6158#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Douglas Gregor</span> to <span class="trac-author">Brandon Kohn</span> </li> </ul> <p> IMO this is the wrong fix: our code should make no assumptions about the actual type of uintXX_t etc. </p> <p> IMO the preprocessed headers are just plain wrong - you can't mix concrete types (char short etc) with typedefs (intXX_t) because you're just asking for problems with duplicate specializations. It has to be all real types throughout. </p> <p> BTW in addition to the two platforms mentioned above, this is also broken for Sun on Linux. </p> <p> Reassigning to the person who made these changes... </p> Ticket Brandon Kohn Sat, 28 Jan 2012 15:06:31 GMT <link>https://svn.boost.org/trac10/ticket/6158#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6158#comment:3</guid> <description> <p> I'll have a look at making these use the fundamental types. As a workaround you can use the following macro to disable these definitions: </p> <p> #define BOOST_NUMERIC_CONVERSION_RELAX_BUILT_IN_CAST_TRAITS </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 28 Jan 2012 15:32:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6158#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6158#comment:4</guid> <description> <p> I think the proper way to solve this is to have a single set of typedefs with the guarantee that those types/typedefs uniquely cover (disjointly) the range of fundamental types on each platform. I had naively assumed this was the case with the cstdint defs. I threw the char one in after a discussion on the mailing list which informed me that char/signed char/unsigned char were always 3 distinct types according to the standard. I suppose the most pragmatic way forward will be to define a sequence of types for each platform (with common ones rolled into sets), and then use those to generate the specializations. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 28 Jan 2012 18:35:00 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6158#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6158#comment:5</guid> <description> <blockquote class="citation"> <p> I think the proper way to solve this is to have a single set of typedefs with the guarantee that those types/typedefs uniquely cover (disjointly) the range of fundamental types on each platform. I had naively assumed this was the case with the cstdint defs. I threw the char one in after a discussion on the mailing list which informed me that char/signed char/unsigned char were always 3 distinct types according to the standard. I suppose the most pragmatic way forward will be to define a sequence of types for each platform (with common ones rolled into sets), and then use those to generate the specializations. </p> </blockquote> <p> I don't think that would work - besides the complete range of types are those given in the C++ standard: </p> <p> char, unsigned char, signed char, short, unsigned short, int, unsigned int, long unsigned long. </p> <p> Plus only if BOOST_NO_LONG_LONG is not defined: long long and unsigned long long long. </p> <p> True there may be other compiler specific types hidden away - MS has <code>__int8</code> <code>__int16</code> etc which may or may not be distinct types depending on the compiler version. But I assume that the default template instantiation can cover any extra compiler specific types? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 28 Jan 2012 19:14:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6158#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6158#comment:6</guid> <description> <p> Yeah, what you propose is how I am handling it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Brandon Kohn</dc:creator> <pubDate>Sat, 28 Jan 2012 20:02:56 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/6158#comment:7 https://svn.boost.org/trac10/ticket/6158#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Brandon Kohn Sat, 28 Jan 2012 20:03:48 GMT <link>https://svn.boost.org/trac10/ticket/6158#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6158#comment:8</guid> <description> <p> A fix is up in the trunk. Please test on those platforms at your earliest convenience. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Randy</dc:creator> <pubDate>Tue, 31 Jan 2012 00:05:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6158#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6158#comment:9</guid> <description> <p> I had the same problem. I can confirm that it at least compiles now (with your fix, brandon.kohn). </p> </description> <category>Ticket</category> </item> <item> <author>rakesh@…</author> <pubDate>Sat, 04 Feb 2012 15:41:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6158#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6158#comment:10</guid> <description> <p> Works for me with GCC 4.6.2 on <a class="missing wiki">OpenIndiana</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Brandon Kohn</dc:creator> <pubDate>Mon, 27 Feb 2012 14:49:18 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6158#comment:11 https://svn.boost.org/trac10/ticket/6158#comment:11 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> The fix is in the 1.49 release. </p> Ticket