On 3 Aug 2006 21:38:52 -0700, "Lighter" <cq****@gmail.c omwrote in
comp.lang.c++:
Is this a Bug of VS 2005?
No.
We know size_t is not a built-in data type in C++, rather, it is just a
typedef declaration.
However, I found the following code could be normally compiled with VS
2005:
// Note that I don't include any header file in this source file
size_t Test(size_t a)
{
return a;
}
int main()
{
size_t n = Test(8);
return n;
}
Why? Is this really a bug of VS 2005?
It can be considered an extension, and extensions are perfectly valid
as long as they do not affect the behavior of a strictly conforming
program. And this can't, because the program has undefined behavior
by using an undefined type.
Furthermore, an attempt to cause a conflict by adding something like:
typedef double size_t;
....in your source file causes even more undefined behavior because all
typedef's inherited from the C library, which includes size_t, are
reserved for the compiler in both the global and std namespaces.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html