jyknight wrote:

Is there a valid use for having "EHCleanup" that _doesn't_ handle branches 
across it? That is, do we _ever_ need a cleanup to be called only for an 
exception thrown, and not otherwise leaving the scope? I'm just wondering if we 
can simplify things conceptually here and remove an option.

The only case I can think of is, perhaps, constructor's member initializer 
lists.

That is...we apparently accept the following code...and it does, I suppose, 
what one might "expect": skips over construction of "b" and "c" and jumps into 
the middle of the constructor function, from which it returns normally as if 
the object was fully constructed. Using "return" instead of "goto" works too, 
also returning "successfully" from the constructor.
```
struct X { X(int); ~X(); };

struct Test {
    Test() : a(1), b( ({ goto label; 2; }) ), c(3) { label: f();}
    X a, b, c;
};

Test* test() { return new Test(); }
```
But...that really seems like code we should be rejecting as invalid (in which 
case, there need not be a distinction between cleanup due to exception or 
branch).

https://github.com/llvm/llvm-project/pull/80698
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to