| Issue |
166053
|
| Summary |
std::numeric_limits<bool>::traps should be true
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Alcaro
|
```c++
#include <limits>
bool bool_trap() { return std::numeric_limits<bool>::traps; }
bool char_trap() { return std::numeric_limits<char>::traps; }
bool int_trap() { return std::numeric_limits<int>::traps; }
```
Result: false, true, true https://godbolt.org/z/q94jhqjsT
Expected: true, true, true. `true/false` traps just as much as `1/0` (if not optimized out - it is UB).
You can argue that division by false promotes to int, therefore it's not an operation on bool that traps, but if so, char is wrong.
Alternatively, one can argue that the entire `traps` member should be deprecated and removed, since every trapping operation is UB, and reasoning about the behavior of undefined behavior makes no sense.
See also https://github.com/microsoft/STL/pull/5816, where MS-STL asks what `traps` should do.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs