aaron.ballman added a comment.
In D155356#4513303 <https://reviews.llvm.org/D155356#4513303>, @tbaeder wrote:
> One thing I'm wondering though is:
>
> constexpr char A[] = {'1', '2', '3'};
> constexpr double d = __builtin_nans(A);
>
> what's expected here? The given char array is not null-terminated.
The builtin expects a null terminated string, so that should be an invalid
constant expression due to reading off the end of the array.
> Should the interpreter ignore the null byte at the end if it's there?
> `StringRef::getAsInteger()` always returns an error if it encounters one, so
> the currentcode in `InterpBuiltin.cpp` ignores the last byte and will pass
> `12` along for the example above.
Yeah, we should not do that. :-D In GCC, this builtin exists to support the
`nans()` function from
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm (which was proposed
but never adopted); Clang's support is for parity with GCC.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155356/new/
https://reviews.llvm.org/D155356
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits