int volati;

S

sandeep

Here is a declaration:

int volati;

Am I right to think that for the previous ISO Standard (C89) this is an
undefined behavior, but not in the current Standard (C99)? My reasoning
is that a C89 compiler is allowed to treat only the first 6 characters of
any name as significant, so this could be equivalent to

int volatile;

which is a syntax error (Constraint Violation). In C99 the whole name is
significant.

It is interesting in gcc: int volati; compiles fine (not even a
diagnostic), while int volatile; also compiles (should be a syntax error)
but with a message,
warning: useless type name in empty declaration
 
M

Malcolm McLean

Here is a declaration:

int volati;

Am I right to think that for the previous ISO Standard (C89) this is an
undefined behavior, but not in the current Standard (C99)? My reasoning
is that a C89 compiler is allowed to treat only the first 6 characters of
any name as significant, so this could be equivalent to
No, the 6 letter limit refers to identifiers with external linkage,
not to keywords. In an old compiler keywords are tokenized in the
compiler first pass, and the identifiers collected. The identifiers
are then written to the object file in the second pass. (Nowadays
compilation is very heavily optimised and often object files aren't
created at all).
 
E

Eric Sosman

Here is a declaration:

int volati;

Am I right to think that for the previous ISO Standard (C89) this is an
undefined behavior, but not in the current Standard (C99)? My reasoning
is that a C89 compiler is allowed to treat only the first 6 characters of
any name as significant, so this could be equivalent to

int volatile;

which is a syntax error (Constraint Violation). In C99 the whole name is
significant.

No equivalence, no violation. The `volatile' keyword is not
a name, so guarantees/restrictions about names do not apply to it.

Ponder these:

unsigned unsign;
long lonG;
double doubledown;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top