Created on 2024-12-09.00:00:00 last changed 12 months ago
Per the specification, the block scope for a function-try-block does not include the ctor-initializer. Consider the following implementation divergence:
struct A {
A() try : p((struct B*)nullptr) {
B *q;
struct B {};
B *r = q; // EDG, GCC, MSVC: error: cannot convert, two different Bs
} catch (...) {
B *q; // GCC: B not in scope here.
}
void *p;
};
struct C {
C(int B) try : p((struct B*)0) { // GCC: error: shadows parameter; MSVC: error: redefinition of B
} catch (...) { }
void *p;
};
There is also implementation divergence regarding the scope of the ctor-initializer if no function-try-blocks are involved.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2024-12-09 00:00:00 | admin | create | |