473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

compile's problem?

mos
Hi! the following code will run without any error on the VC7.1 stdio
debug mode. who can tell me what's the problem?

struct st
{
int a;
};
int _tmain(int argc, _TCHAR* argv[])
{
st* p = new st;
delete p;
p->a = 0;
return 0;
}

mos.
Aug 6 '07 #1
5 1178
On Aug 6, 7:11 pm, "mos" <mmosqu...@163.comwrote:
Hi! the following code will run without any error on the VC7.1 stdio
debug mode. who can tell me what's the problem?

struct st
{
int a;};

int _tmain(int argc, _TCHAR* argv[])
Non-standard.
{
st* p = new st;
delete p;
p->a = 0;
Undefined behavior.
return 0;
Not necessary.
>
}

mos.
-N

Aug 6 '07 #2
mos wrote:
Hi! the following code will run without any error on the VC7.1 stdio
debug mode. who can tell me what's the problem?

struct st
{
int a;
};
int _tmain(int argc, _TCHAR* argv[])
{
st* p = new st;
delete p;
p->a = 0;
return 0;
}
I'm not really sure what your question is. I assume you know that the
program invokes undefined behaviour. Had you been expecting a
compile-time diagnostic? It is not required.
Aug 6 '07 #3
Neelesh Bodas wrote:
On Aug 6, 7:11 pm, "mos" <mmosqu...@163.comwrote:
Hi! the following code will run without any error on the VC7.1
return 0;
Not necessary.
In spite of the fact that a specific return is not required from
main(), it is not wrong to do so and in my opinion is better code. That
indicates that the programmer did not merely forget it. It certainly
doesn't require "correction" in a newsgroup.


Brian
Aug 6 '07 #4
mos wrote:
Hi! the following code will run without any error on the VC7.1 stdio
debug mode. who can tell me what's the problem?

struct st
{
int a;
};
int _tmain(int argc, _TCHAR* argv[])
{
st* p = new st;
delete p;
p->a = 0;
return 0;
}

mos.
One of the insidious forms of undefined behavior is it working
error free (at least for a short time).
Aug 7 '07 #5
On Aug 7, 1:10 pm, Ron Natalie <r...@spamcop.netwrote:
mos wrote:
Hi! the following code will run without any error on the VC7.1 stdio
debug mode. who can tell me what's the problem?
struct st
{
int a;
};
int _tmain(int argc, _TCHAR* argv[])
{
st* p = new st;
delete p;
p->a = 0;
return 0;
}
One of the insidious forms of undefined behavior is it working
error free (at least for a short time).
The most frequent result of using undefined behavior seems to be
that the code works perfectly in all of the tests, but then
fails in a very visible fashion during the demo in front of the
important client.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Aug 7 '07 #6

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

Similar topics

8
by: janeaustine50 | last post by:
Python's InteractiveInterpreter uses the built-in compile function. According to the ref. manual, it doesn't seem to concern about the encoding of the source string. When I hand in an unicode...
5
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new...
5
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace )...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
9
by: serge | last post by:
I have a stored procedure that is over 1000 + lines of code. When i try to compile I get the following error: ABC.TEST123: 1285: SQL0104N An unexpected token "END" was found following " END...
10
by: Bart Goeman | last post by:
Hi, I have a question about how to put redundant information in data structures, initialized at compile time. This is often necessary for performance reasons and can't be done at run time (data...
10
by: Chris LaJoie | last post by:
Our company has been developing a program in C# for some time now, and we haven't had any problems with it, but just last night something cropped up that has me, and everyone else, stumped. I...
6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
6
by: Tom | last post by:
I am developing my pages on my development machine and then copying to the production server. I am not pre-compiling, I am using the 'dynamic compile' feature. This is working fine except that...
0
by: Jérôme Le Bougeant | last post by:
Hello (and sorry for my English), I downloaded the VideoCapture module on the http://videocapture.sourceforge.net/ site. I tested it with a webcam and that functions. Now I want to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
agi2029
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,...

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.