Boost C++ Libraries: Ticket #8367: chrono does not compile with clang from XCode 4.5.2 with -std=c++11 -stdlib=libc++ and -arch armv7 https://svn.boost.org/trac10/ticket/8367 <p> When trying to compile chrono with the Xcode 4.5.2 clang compiler on MacOS X for iOS with </p> <p> -std=c++11 -stdlib=libc++ and -arch armv7 </p> <p> one gets compile errors. Compile log attached. </p> <p> I'm using the following configuration and everything is right. </p> <pre class="wiki">using clang : 3.2 : /Users/viboes/clang/clang+llvm-3.2-x86_64-apple-darwin11/bin/clang++ ; using clang : 3.2xl : /Users/viboes/clang/clang+llvm-3.2-x86_64-apple-darwin11/bin/clang++ : &lt;cxxflags&gt;"-std=c++11 -stdlib=libc++" &lt;linkflags&gt;"-std=c++11 -stdlib=libc++" ; </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8367 Trac 1.4.3 Franz Detro <franz.detro@…> Tue, 02 Apr 2013 10:02:21 GMT attachment set https://svn.boost.org/trac10/ticket/8367 https://svn.boost.org/trac10/ticket/8367 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">clang_chrono.txt</span> </li> </ul> Ticket viboes Mon, 08 Apr 2013 17:44:33 GMT status, description changed https://svn.boost.org/trac10/ticket/8367#comment:1 https://svn.boost.org/trac10/ticket/8367#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/8367?action=diff&amp;version=1">diff</a>) </li> </ul> <p> The error appears when the standard library doesn't uses constexpr for max() </p> <pre class="wiki">41 ./boost/chrono/duration.hpp:353:49: error: constexpr function never produces a constant expression 42 static BOOST_CHRONO_LIB_CONSTEXPR float lowest() BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW 43 ^ 44 ./boost/chrono/duration.hpp:355:21: note: non-constexpr function 'max' cannot be used in a constant expression 45 return -(std::numeric_limits&lt;float&gt;::max) (); 46 ^ </pre><p> BOOST_CHRONO_LIB_CONSTEXPR is defined as follows </p> <pre class="wiki">#if defined( BOOST_NO_CXX11_NUMERIC_LIMITS ) #define BOOST_CHRONO_LIB_CONSTEXPR #elif defined(_LIBCPP_VERSION) &amp;&amp; _LIBCPP_VERSION &lt; 1002 #define BOOST_CHRONO_LIB_CONSTEXPR #else #define BOOST_CHRONO_LIB_CONSTEXPR BOOST_CONSTEXPR #endif </pre><p> Could you tell me what is the value of BOOST_NO_CXX11_NUMERIC_LIMITS and _LIBCPP_VERSION on the environment you get the error? </p> Ticket Franz Detro <franz.detro@…> Tue, 09 Apr 2013 07:05:15 GMT <link>https://svn.boost.org/trac10/ticket/8367#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8367#comment:2</guid> <description> <p> BOOST_NO_CXX11_NUMERIC_LIMITS is undefined. </p> <p> Here's the extract of clangs config file: </p> <pre class="wiki">#define _LIBCPP_VERSION 1101 #define _LIBCPP_ABI_VERSION 1 </pre><p> The problem is related to the combination of -std=c++11 and -stdlib=libc++. If I use only one of them, everything is fine. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Tue, 09 Apr 2013 07:50:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8367#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8367#comment:3</guid> <description> <p> This was fixed (by Apple) as part of the Xcode 4.6 release. </p> <p> Specifically, <code>std::numeric_limits&lt;&gt;::max()</code> is now constexpr. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 10 Apr 2013 17:01:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8367#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8367#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8367#comment:2" title="Comment 2">Franz Detro &lt;franz.detro@…&gt;</a>: </p> <blockquote class="citation"> <p> BOOST_NO_CXX11_NUMERIC_LIMITS is undefined. </p> <p> Here's the extract of clangs config file: </p> <pre class="wiki">#define _LIBCPP_VERSION 1101 #define _LIBCPP_ABI_VERSION 1 </pre><p> The problem is related to the combination of -std=c++11 and -stdlib=libc++. If I use only one of them, everything is fine. </p> </blockquote> <p> Please could you try the following patch </p> <pre class="wiki">#if defined( BOOST_NO_CXX11_NUMERIC_LIMITS ) #define BOOST_CHRONO_LIB_CONSTEXPR #elif defined(_LIBCPP_VERSION) &amp;&amp; _LIBCPP_VERSION &lt;= 1101 #define BOOST_CHRONO_LIB_CONSTEXPR #else #define BOOST_CHRONO_LIB_CONSTEXPR BOOST_CONSTEXPR #endif </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 10 Apr 2013 17:02:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8367#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8367#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8367#comment:3" title="Comment 3">marshall</a>: </p> <blockquote class="citation"> <p> This was fixed (by Apple) as part of the Xcode 4.6 release. </p> <p> Specifically, <code>std::numeric_limits&lt;&gt;::max()</code> is now constexpr. </p> </blockquote> <p> Do you know since which _LIBCPP_VERSION this is fixed? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Wed, 10 Apr 2013 20:34:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8367#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8367#comment:6</guid> <description> <p> _LIBCPP_VERSION was changed to 1101 soon after <code>std::numeric_limits&lt;&gt;::max()</code> was marked as constexpr. </p> <p> You can check for that, or use <code>#ifdef _LIBCPP_CONSTEXPR</code> which was added at the same time as the change. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 11 Apr 2013 06:00:16 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8367#comment:7 https://svn.boost.org/trac10/ticket/8367#comment:7 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> <p> Thanks for the info. Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/83842" title="Chrono: use libc++ constexpr if _LIBCPP_CONSTEXPR is defined #8367.">[83842]</a>. </p> Ticket viboes Sat, 13 Apr 2013 12:56:33 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8367#comment:8 https://svn.boost.org/trac10/ticket/8367#comment:8 <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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83866" title="Chrono: merge to fix #8367.">[83866]</a>) Chrono: merge to fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8367" title="#8367: Bugs: chrono does not compile with clang from XCode 4.5.2 with -std=c++11 ... (closed: fixed)">#8367</a>. </p> Ticket