Full name of submitter (unless configured in github; will be published with the issue): Jay Ghiron
Reference (section label): [diff.stat]
Issue description:
See C DR 466:
static inline int f (void) {
for (int i = 0; ; ) {
long i = 1; // valid C, invalid C++
// ...
return i; // (perhaps unexpectedly) returns 1 in C
}
}
In C2Y the same also applies to if and switch.
Partial suggested resolution:
Create a new paragraph at the end of [diff.stat]:
Affected subclause: [stmt.for]
Change: Names declared inside of the init-statement of a for loop have the same scope as names declared directly in the statement of the same for loop.
[Example 1:
for(int i=0;;){
int i=1; // valid C, invalid in C++
return i;
}
- end example]
Rationale: <to be decided>
Effect on original feature: Change to semantics of well-defined feature.
Difficulty of converting: Syntactic transformation. A second compound statement will allow reusing the name.
How widely used: Seldom.
Full name of submitter (unless configured in github; will be published with the issue): Jay Ghiron
Reference (section label): [diff.stat]
Issue description:
See C DR 466:
In C2Y the same also applies to if and switch.
Partial suggested resolution:
Create a new paragraph at the end of [diff.stat]: