https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109991

--- Comment #3 from igk <igkper at gmail dot com> ---
(In reply to Andrew Pinski from comment #2)
> Dup of bug 98675.
> 
> *** This bug has been marked as a duplicate of bug 98675 ***

Thanks for looking into this. I haven't quite understood though. 

I'm trying to see if I can find what you're saying that it should be rejected
in the C++ 14 standard (the version I have). The closest things I can find are
the following. Are they the relevant parts?

```
For a non-template, non-defaulted constexpr function or a non-template,
non-defaulted, non-inheriting constexpr constructor, if no argument values
exist such that an invocation of the function or constructor could be an
evaluated subexpression of a core constant expression (5.19), the program is
ill-formed; no diagnostic required.
```
where (5.19) includes
```
A conditional-expression e is a core constant expression unless the evaluation
of e, following the rules of the
abstract machine (1.9), would evaluate one of the following expressions:
...
- an operation that would have undefined behavior,..
```

In my example, the function takes no arguments so there are no argument values
"such that an invocation of the function or constructor could be an evaluated
sub-expression of a core constant expression". This would make my program
"ill-formed, no diagnostic required". I interpret this as saying the compiler
isn't required to reject the code. Perhaps I'm on the wrong track, but I'm
wondering, isn't such UB something sanitizer aims to catch?

Also, (not an issue with sanitizer) to me it seems odd that GCC would do
constexpr evaluation when "BadWrapUse c;" is not declared as a constexpr
variable, rather than not avoiding it because it is not valid.

Reply via email to