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
16 1341
Darwin Lalo wrote:
Ian Collins wrote:
>Darwin Lalo wrote:
>>Some "Header Files" is Default Includes.
Name one.
<stdlib.h>
Not in a strictly conforming implementation. MSVC may do this, but it's
not standard behavior.
--
Mike Smith
"Darwin Lalo" <co********@gma il.comskrev i meddelandet
news:11******** *************@m 79g2000cwm.goog legroups.com...
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.
Not really, but size_t is the type of the return value of the sizeof
operator. That can be used without including any headers, so the
compiler must have builtin knowledge of size_t. This is just made
visible here.
Bo Persson
Bo Persson wrote:
>
Not really, but size_t is the type of the return value of the sizeof
operator. That can be used without including any headers, so the
compiler must have builtin knowledge of size_t. This is just made
visible here.
It does not need to be visible. The sizeof operator is quite
capable of working without the NAME size_t being defined. It
does on just about any other compiler OTHER than visual studio.
On 4 Aug 2006 02:24:42 -0700, "Darwin Lalo" <co********@gma il.com>
wrote in comp.lang.c++:
>
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.
That was my first thought, but did you see the note the OP put above
the function? C++ specifically allows any standard header to include
any or all other standard headers. But it certainly does not give the
implementation permission to include any standard headers in a
translation unit that includes nothing.
--
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
On Fri, 04 Aug 2006 12:47:40 +0200, "Alf P. Steinbach"
<al***@start.no wrote in comp.lang.c++:
* 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.
The OP said it "compiled normally", which to me means it produced an
executable. He did not specify whether or not it issued a diagnostic.
--
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
On Fri, 04 Aug 2006 08:10:25 -0400, Ron Natalie <ro*@spamcop.ne t>
wrote in comp.lang.c++:
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.
The OP said it "compiled normally", which to me means it produced an
executable. He did not specify whether or not it issued a diagnostic.
--
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
Jack Klein wrote:
The OP said it "compiled normally", which to me means it produced an
executable. He did not specify whether or not it issued a diagnostic.
I'm the OP. I meant that VS 2005 did not give any error or warning
message during it compiled the code mentioned above. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
|
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...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
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...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |