head -r320458 (e.g.) amd64 -> powerpc (32-bit) cross-buildworld fails for time libc++ static_asserts and overflow/underflow of long long (system clang/clang++ 4 based build)
Dimitry Andric
dim at FreeBSD.org
Thu Jun 29 21:46:53 UTC 2017
On 29 Jun 2017, at 19:16, Mark Millard <markmi at dsl-only.net> wrote:
>
> On 2017-Jun-29, at 5:54 AM, Konstantin Belousov <kostikbel at gmail.com> wrote:
>>
>> On Thu, Jun 29, 2017 at 12:47:10PM +0200, Dimitry Andric wrote:
>>> One nasty problem with this is that it is not possible to figure out at
>>> compile time what the size of time_t is. You always need some sort of
>>> configure-time test, and an external define.
>>
>> It is arguably possible, with constexpr.
>
> I took Dimitry's wording as probably referring to
> testing the size in the C/C++ preprocessor like
> the original code tests for __LP64__ being defined
> vs. not to control what it does: extending that to
> involve more preprocessor tests to pick from more
> code blocks. (But it is a guess given his wording.)
Yeah, what I meant is that the code does something like:
#if __LP64__
static_assert(whatever, "foo");
#else
static_assert(otherthing, "bar");
#endif
where __LP64__ was erroneously thought to determine whether time_t was
64-bit. You cannot replace this with something like the following C++11
construct, though:
constexpr bool time_t_64bit = sizeof(time_t) == 8;
if (time_t_64bit)
static_assert(true, "time_t is OK");
else
static_assert(false, "time_t is bad");
because both static assertions will be evaluated at compile time, and
one of them will fail.
In any case, Eric Fiselier already had some sort of patch lined up, but
I slacked off on trying it out. Sorry about that. :)
-Dimitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freebsd.org/pipermail/freebsd-toolchain/attachments/20170629/fe42b159/attachment.sig>
More information about the freebsd-toolchain
mailing list