tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Scoping fix


From: Elijah Stone
Subject: Re: [Tinycc-devel] Scoping fix
Date: Thu, 21 Jan 2021 14:20:35 -0800 (PST)

On Thu, 21 Jan 2021, Michael Matz wrote:

You can't declare a struct in the declaration part of the for stmt (6.8.5p3), only objects of auto and register class.

Hmmm.  I think the spec is somewhat ambiguous here.
The specific wording is:

The declaration part of a for statement shall only declare identifiers for objects having storage class auto or register

Does that mean that:

1. all objects which have identifiers declared for them must have
   storage class auto or register

2. all identifiers which are declared must be for objects, and those
   objects must have storage class auto or register

FWIW both gcc and clang seem to nominally follow interpretation 2 (they're not consistent about it). But I think there's a case to be made for interpretation 1. In particular, it seems somewhat sensible to disallow something like 'for (extern int x;;)'. But disallowing

for (int x = sizeof(struct foo { int m; });;)

while allowing

int x = sizeof(struct foo { int m; });

seems arbitrary and inconsistent.

(Maybe I'll write a paper for WG14.  Make them disambiguate!)

 -E



reply via email to

[Prev in Thread] Current Thread [Next in Thread]