Re: [PATCH] c++: unevaluated array new-expr size constantness [PR108219]

2023-03-01 Thread Patrick Palka via Gcc-patches
> > > > > call fold? > > > > > > > > That seems like a good compromise between proper constant evaluation > > > > and not constant evaluating at all, though I wonder how 'fold' behaves > > > > w.r.t. to undefined behavior suc

Re: [PATCH] c++: unevaluated array new-expr size constantness [PR108219]

2023-03-01 Thread Jason Merrill via Gcc-patches
o folds e.g. x*1 to x. I suppose we want to be pretty conservative with the constantness test, so I went with CONSTANT_CLASS_P && !TREE_OVERFLOW. Makes sense. Like so? Smoke tested so far, bootstrap and regtest on x86_64-pc-linu-xgnu in progress. -- >8 -- Subject: [PATCH] c++:

Re: [PATCH] c++: unevaluated array new-expr size constantness [PR108219]

2023-03-01 Thread Patrick Palka via Gcc-patches
nk we should only return the > result of 'fold' at this point if it is in fact constant, not if it's a > non-constant simplification. Sounds good, I wasn't sure if 'fold' could return a non-constant simplification. I suppose we want to be pretty conservative with the

Re: [PATCH] c++: unevaluated array new-expr size constantness [PR108219]

2023-03-01 Thread Jason Merrill via Gcc-patches
#x27;fold' at this point if it is in fact constant, not if it's a non-constant simplification. IIUC proper constant evaluation treats UB as non-constant, so it might be potentially problematic if 'fold' instea dtakes advantage of UB. Or maybe since we're in an unevalua

Re: [PATCH] c++: unevaluated array new-expr size constantness [PR108219]

2023-03-01 Thread Patrick Palka via Gcc-patches
behavior such as division by zero and signed overflow? IIUC proper constant evaluation treats UB as non-constant, so it might be potentially problematic if 'fold' instea dtakes advantage of UB. Or maybe since we're in an unevaluated context it doesn't matter? -- >8 -- Su

Re: [PATCH] c++: unevaluated array new-expr size constantness [PR108219]

2023-02-27 Thread Jason Merrill via Gcc-patches
On 2/22/23 14:45, Patrick Palka wrote: Here we're mishandling the unevaluated array new-expressions due to a supposed non-constant array size ever since r12-5253-g4df7f8c79835d569, made us no longer perform constant evaluation of non-manifestly-constant expressions within unevaluated contexts. T

[PATCH] c++: unevaluated array new-expr size constantness [PR108219]

2023-02-22 Thread Patrick Palka via Gcc-patches
Here we're mishandling the unevaluated array new-expressions due to a supposed non-constant array size ever since r12-5253-g4df7f8c79835d569, made us no longer perform constant evaluation of non-manifestly-constant expressions within unevaluated contexts. This shouldn't make a difference here sinc