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
[expr.new] Harmonize rules of constant array bounds > 0 #2327
[expr.new] Harmonize rules of constant array bounds > 0 #2327
Conversation
I agree with the change, but I disagree with the side note. The previous wording used "integral constant expression", which could have been of a signed integer type and therefore would have allowed for negative values. The "converted constant expression of type std::size_t" indeed relies on the absence of narrowing, and I believe the wording (before and after) correctly requires a diagnostic for "new int[-1]", for instance. |
I don't see in what point you disagree. To clarify what I said, let me My naive reading was "Huh? Evaluating -1 as std::size_t will yields a struct S { constexpr operator int () const { return -1; } };
int a[S()]; gcc 8.2.0 says "error: size of array 'a' is negative". Hmm. |
The spelling of error messages is not in scope for the standard. |
Putting this on hold: I'd like to either resolve the more-substantial #2274 first, or merge this into that. |
This change is subsumed by #2274. |
Let's close this and concentrate on #2274 then. |
After all, this is not covered by #2274. |
While "shall evaluate to a strictly positive value" is not wrong, "shall be greater than zero" is easier and is used in [dcl.array] to describe the same rule.
16f1ec6
to
8226cbd
Compare
Rebased. |
While "shall evaluate to a strictly positive value" is not wrong,
"shall be greater than zero" is easier and is used in [dcl.array] and
[dcl.init.aggr] to describe the same rule.
As a side note, I was surprized that negative bounds are not actually
banned by these "shall be greater than zero". It is now banned by a
narrowing conversion involved in a "converted constant expression of
type std::size_t" since approval of N3323(390dd71#diff-baa06f0d56d1de4d541e8b3fca69df74).
Now these "shall be greater than zero" actually ban only zero.
But I think changing them to "shall not be zero" is not good (can be
more confusing).