[llvm-bugs] [Bug 48402] Rejects valid subscript expression on array of unknown bound in constant expression

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 8 00:12:40 PST 2020


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

Richard Smith <richard-llvm at metafoo.co.uk> changed:

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

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
Expressions with undefined behavior are non-constant, and in particular it is
not possible to create an out-of-bounds array index in a constant expression.

It's not possible for a compiler to know whether your example has defined
behavior or not, so the only conservatively-correct thing we can do is reject.
I reported this to the C++ committee a few years back, and there was support
for rejecting cases such as this, but the standard hasn't yet been updated to
match.

Resolving WONTFIX for now: the behavior is intentional, and we expect the
standard to change to match. But this will be revisited if the standard goes in
a different direction.

-- 
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/20201208/3771b91a/attachment.html>


More information about the llvm-bugs mailing list