-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang++ incorrectly accepts addition with an array prvalue operand #54016
Comments
@llvm/issue-subscribers-clang-frontend |
I believe clang is correct here, we apply a standard conversion [conv.general] which includes array-to-pointer conversion [conv.array] which results in a temporary materialization conversion [conv.rval]. A quick godbolt with AST output seems to confirm this what clang is doing. This 2018 cfe-dev mailing on a related case seems to indicate that clang is correct and although "GCC's behaviour is not unreasonable" CC @zygoloid Clang has -Waddress-of-temporary but looking at the test suite in:
It looks like we purposely do not consider the array-to-pointer conversion to be included as taking the address of a temporary. Although I can see the case can be made for clang to be stricter. Note, |
And why it should be applied here? |
I see, your argument is that [basic.lval]/6 does not apply because the array operand is not a glvalue? I don't think that's the intent of CWG1232, but it does seem to be what the current wording says. This seems worth a CWG discussion before we proceed. |
Exactly.
e-mail thread or immediate issue request? |
I think it's OK to go straight to filing an issue (github.com/cplusplus/cwg/issues), given that I think it's at least unclear whether the wording reflects the intent. |
Also would like to point out [conv.general]p2.1 says:
Although this is a note and this non-normative I think it speaks to the intent. |
Created core issue 2548. |
No, it is just a defective Note. See https://timsong-cpp.github.io/cppwp/n4868/dcl.init.general#def:destination_type. Operand of a built-in operator is not «object or reference being initialized». |
Note the GCC issue side is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94264 . |
CWG forwarded the issue to EWG: cplusplus/papers#1633 There's no clear indication yet of whether prvalue arrays should be subject to the array-to-pointer conversion when they appear as the operand of |
You mean |
Related discussion: https://stackoverflow.com/q/77051011/7325599 |
I meant |
[expr.add]/1:
Array types are not allowed. Neither there is wording requiring the array-to-pointer conversion on a prvalue array operand.
The text was updated successfully, but these errors were encountered: