Re: 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)

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Thu, 29 Jun 2017 23:46:25 +0200
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


Received on Thu Jun 29 2017 - 19:46:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:12 UTC