-
Notifications
You must be signed in to change notification settings - Fork 7
CWG3018 [cpp.cond] Ambiguous validity of defined
in __has_embed
#694
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
Comments
I notice that the phrasing in [cpp.embed.param.limit] p1 is bad regardless:
There is no constant-expression at that point; it is formed later in p2. |
I'm confused. This sounds like it's fine to have Should we just specify for |
Or do you want to simply allow |
This alternative was why we disallowed |
Yes, it can be fine. If we want it to be fine, I said that we should specify that the evaluation of
I don't think so. |
I'm sure I'm being stupid here, but let's start at the beginning, please. For #embed, we (nowadays) macro-expand the entire thing without protecting macro names after "defined". For the limit parameter, we branch off to the
So, we make sure we get a deterministic error message in such a case. Example:
yields
which would work after applying the Now, on to
There, we are in an So, we want your original suggestion:
Alternatively, we could say we don't evaluate |
Sounds good to me. |
I've also disallowed
for symmetry. But |
defined
in __has_embed
defined
in __has_embed
Full name of submitter (unless configured in github; will be published with the issue): Hubert Tong
Reference (section label): cpp.cond
Link to reflector thread (if any): N/A
Issue description:
Consider (with the proposed
offset
parameter for a more plausible use case):It is unclear whether the above is ill-formed due to https://wg21.link/cpp.embed.param.limit#1 because https://wg21.link/cpp.cond#12 can be read as saying that the evaluation of the defined-macro-expression has occurred prior to the evaluation of the has-embed-expression.
Suggested resolution:
Add a restriction that
"Editor's" note: This is for consistency with the restriction in the context of
#embed
, which is (in turn) motivated by the special macro expansion logic associated withdefined
only in the [cpp.cond] context. Since we are already in the [cpp.cond] context for__has_embed
, there is no major design barrier for specifying that the defined-macro-expressions are evaluated first.The text was updated successfully, but these errors were encountered: