strange warning

J

Jerry Coffin

[ ... ]
In C99, size_t does not have to be a synonym for an
integral type (although it does in C90, as you point out).

C99, section 7.17/2 contains almost identical wording to that from
the C90 standard, saying that size_t is: "the unsigned integer type
of the result of the sizeof operator;"

The only difference is that "integral" has been changed to "integer".

There is one fundamental change, however: C99 has the "standard
unsigned integer types", which are basically synonymous with what C90
called the unsigned integer types. It also, however, has the
possibility of "extended unsigned integer types", which are
implementation defined. The "unsigned integer types", are basically a
union of the standard and extended unsigned integer types.

That means in C99, and presumably C++ 0x, size_t might not be a
synonym for any standard type. I guess, in theory, it doesn't
restrict extended unsigned integer types to types that are unsigned
or integers, so (in theory) somebody could define "double" as being
an extended unsigned integer type -- but even as strict as I am about
interpreting the standard only for what it requires and not what it
almost certainly means, it's hard for even me to imagine anybody
defining something as an "extended unsigned integer" unless it truly
is 1) unsigned, and 2) an integer type.
 
K

Kai-Uwe Bux

Jerry said:
[ ... ]
In C99, size_t does not have to be a synonym for an
integral type (although it does in C90, as you point out).

C99, section 7.17/2 contains almost identical wording to that from
the C90 standard, saying that size_t is: "the unsigned integer type
of the result of the sizeof operator;"

The only difference is that "integral" has been changed to "integer".

There is one fundamental change, however: C99 has the "standard
unsigned integer types", which are basically synonymous with what C90
called the unsigned integer types. It also, however, has the
possibility of "extended unsigned integer types", which are
implementation defined. The "unsigned integer types", are basically a
union of the standard and extended unsigned integer types.

That means in C99, and presumably C++ 0x, size_t might not be a
synonym for any standard type. I guess, in theory, it doesn't
restrict extended unsigned integer types to types that are unsigned
or integers, so (in theory) somebody could define "double" as being
an extended unsigned integer type -- but even as strict as I am about
interpreting the standard only for what it requires and not what it
almost certainly means, it's hard for even me to imagine anybody
defining something as an "extended unsigned integer" unless it truly
is 1) unsigned, and 2) an integer type.

I guess, the interesting question will be whether an implementation will be
required to provide overloaded operators (say for stream output) for those
extended integer types.


Best

Kai-Uwe Bux
 
O

Old Wolf

Jerry said:
(e-mail address removed) says...


That means in C99, and presumably C++ 0x, size_t might not be a
synonym for any standard type.

That was my point (clearly it is unsigned and integral).

If C++0x adopts that part of C99, but it does not provide
a specific ostream::eek:perator<< overload for size_t, then
the warning in the original code would actually be valid :)
 
J

Jerry Coffin

[ ... ]
I guess, the interesting question will be whether an implementation will be
required to provide overloaded operators (say for stream output) for those
extended integer types.

That, in turn, leads to other interesting questions, such as: if they
do exist, where to they live? Are they part of namespace std, or
should there be some other namespace specifically for implementation
defined extensions? What header do you need to include to get the
declared? Again, should they be along with the standard ones, or in a
special, separate header?
 
J

Jerry Coffin

[ ... ]
That was my point (clearly it is unsigned and integral).

Oh, I wasn't trying to argue against that. Mostly I thought it might
make sense to go into more detail for those less familiar with the
standard, so they might not understand your reasoning (especially,
since the nearly identical wording in the new C standard had been
quoted elsethread, but without any indication about the fact that the
meaning had changed even though the words were essentially
identical).
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top