[llvm-bugs] [Bug 43685] Constexpr new: uncatched UB in constant context

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 16 11:09:50 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43685

David Blaikie <dblaikie at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #4 from David Blaikie <dblaikie at gmail.com> ---
(In reply to Alexander Zaitsev from comment #3)
> I don't know a lot about internals and how it can be detected (I trust you
> that checking something like that is undetectable). But if it's undefined
> behavior in C++ standard it shall lead to compile error in constexpr (AFAIK
> constexpr context cannot have UB inside and all code with UB shall lead to
> compile error).

So the wording in C++17 is as follows:

8.20 [expr.const] p2

"An expression e is a core constant expression unless the evaluation of e,
following the rules of the abstract machine (4.6), would evaluate one of the
following expressions:"
...
"an operation that would have undefined behavior as specified in Clauses 4
through 19 of this document"

That specifically does not include Clause 20, which is where the standard
library is defined.

So I believe the compiler behavior you're observing is conforming, though the
code is non-portable (as it's /possible/ that some other implementation might
have UB (as specified in Clauses 4 through 19) on these codepaths - but it's
not required that they do).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191016/082c4e3a/attachment.html>


More information about the llvm-bugs mailing list