The attribute is ignored unless it is placed on the in-class declaration of the member. It has no effect when applied to the explicit definition. I would rather keep the workaround internal than make the change in the headers.
On Fri, Jul 1, 2016 at 5:34 PM, Richard Smith <rich...@metafoo.co.uk> wrote: > On Fri, Jul 1, 2016 at 4:22 PM, Eric Fiselier via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: ericwf >> Date: Fri Jul 1 18:22:25 2016 >> New Revision: 274403 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev >> Log: >> Work around ABI break caused by C++17 inline variables. >> >> Modified: >> libcxx/trunk/src/chrono.cpp >> >> Modified: libcxx/trunk/src/chrono.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff >> >> ============================================================================== >> --- libcxx/trunk/src/chrono.cpp (original) >> +++ libcxx/trunk/src/chrono.cpp Fri Jul 1 18:22:25 2016 >> @@ -6,7 +6,7 @@ >> // Source Licenses. See LICENSE.TXT for details. >> // >> >> >> //===----------------------------------------------------------------------===// >> - >> +#define _LIBCPP_BUILDING_CHRONO >> #include "chrono" >> #include "cerrno" // errno >> #include "system_error" // __throw_system_error >> @@ -32,6 +32,9 @@ namespace chrono >> // system_clock >> >> const bool system_clock::is_steady; >> > > Can you mark this as __attribute__((used)) instead of adding a separate > use? > > >> +// Make is_steady non-discardable in C++17 >> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) >> +static const bool& __is_steady_force_use1 __attribute__((used)) = >> system_clock::is_steady; >> >> system_clock::time_point >> system_clock::now() _NOEXCEPT >> @@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE >> // instead. >> >> const bool steady_clock::is_steady; >> +// Make is_steady non-discardable in C++17 >> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395) >> +static const bool& __is_steady_force_use2 __attribute__((used)) = >> steady_clock::is_steady; >> + >> >> #ifdef CLOCK_MONOTONIC >> >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits