[llvm-bugs] [Bug 50342] New: Missing diagnostic for comma in constant expression
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 14 09:45:24 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50342
Bug ID: 50342
Summary: Missing diagnostic for comma in constant expression
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: john.brawn at arm.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
In the C11 (and earlier) standard it says in section 6.6 about constant
expressions:
Constant expressions shall not contain assignment, increment, decrement,
function-call,
or comma operators, except when they are contained within a subexpression
that is not
evaluated.
Which means we should be giving a diagnostic for code like this
static const int i = 0 ? 2 : ((void)3, 4);
There's a comment in clang/lib/Sema/SemaDecl.cpp about this:
// FIXME: Need strict checking. In C89, we need to check for
// any assignment, increment, decrement, function-calls, or
// commas outside of a sizeof. In C99, it's the same list,
// except that the aforementioned are allowed in unevaluated
// expressions. Everything else falls under the
// "may accept other forms of constant expressions" exception.
--
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/20210514/9915a518/attachment.html>
More information about the llvm-bugs
mailing list