473,796 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is this a Bug of VS 2005?

Is this a Bug of VS 2005?

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?

Aug 4 '06 #1
16 1340
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
Aug 4 '06 #2
to Jack Klein:

Thank you for your answer. However, I don't think this is an extension
for C++ made by VS 2005. The reason for this is that VS 2005 can still
correctly compile the code above-mentioned even I set the compiler
option /Za.

Aug 4 '06 #3

Lighter 写道:
Is this a Bug of VS 2005?

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?


Some "Header Files" is Default Includes.

Aug 4 '06 #4
Darwin Lalo wrote:
Some "Header Files" is Default Includes.
Are you sure? Where can I find the reference?

Aug 4 '06 #5
Darwin Lalo wrote:
>
Some "Header Files" is Default Includes.
Name one.

--
Ian Collins.
Aug 4 '06 #6
* Jack Klein:
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,
Yes.
and extensions are perfectly valid
as long as they do not affect the behavior of a strictly conforming
program.
Yes, but a diagnostic must be issued (in standards-compliant mode). The
compiler can then go on to compile the rest with no further diagnostics.

I think it's a bug, possibly one intentionally introduced to make some
code that relies on this behavior, compile cleanly.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Aug 4 '06 #7
Jack Klein wrote:
>
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.
Except the compiler should say something. The program is ill-formed.
Aug 4 '06 #8
Many years ago, I read it.
I think it it's trivial.
"NULL" is the same.
Darwin Lalo wrote:
Some "Header Files" is Default Includes.

Are you sure? Where can I find the reference?
Aug 4 '06 #9

Ian Collins wrote:
Darwin Lalo wrote:

Some "Header Files" is Default Includes.
Name one.
<stdlib.h>

Aug 4 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
9529
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10457
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5443
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.