Skip to content

[stmt.for] Missing curly brackets in for-statement translation #7211

Open
@Eelis

Description

@Eelis

According to [stmt.for],

for (; false; ++i) int i = 5;

is equivalent to:

{
    ;
    while (false) {
        int i = 5;
        ++i;
    }
}

which is well-formed. But this is clearly not the intent, and all compilers I tried reject the for loop above (when there is no other i around, of course).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions