From 1333310988144331606
X-Google-Thread: f78e5,3c316a202087bfac
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: aon.912719634@aon.at (Nicolas Pavlidis)
Newsgroups: comp.std.c++
Subject: Re: Defining undefined, etc., behavior
Date: Tue, 18 Apr 2006 16:57:31 GMT
Lines: 118
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <4444e14a$0$3888$91cee783@newsreader01.highway.telekom.at>
References: <123m587c3abqge4@corp.supernews.com> <pUO%f.8128$j7.296623@news.indigo.ie> <4442b95c$0$12939$91cee783@newsreader02.highway.telekom.at> <4ah3ofFt9979U1@individual.net>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: news.demon.co.uk 1145379459 14026 158.152.254.254 (18 Apr 2006 16:57:39 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 18 Apr 2006 16:57:39 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Thunderbird 1.5 (Windows/20051201)
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id k3IGvVcU025648;
	Wed, 19 Apr 2006 02:57:31 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:1594

Bo Persson wrote:
> "Nicolas Pavlidis" <aon.912719634@aon.at> skrev i meddelandet 
> news:4442b95c$0$12939$91cee783@newsreader02.highway.telekom.at...
>> Hi!
>>
>> Again a disclaimer: I'm far away from beeing an expert, but I whant 
>> to
>> take this thread to note some things, which seem anoying to me.
>>
>> NULL@NULL.NULL wrote:
>>> Scott Meyers posted:
>>>
>>>> What work has been done on eliminating undefined behavior in C or 
>>>> C++?
>>>> Off the top of my head, some undefined behavior is due to "stupid 
>>>> user
>>>> behavior," e.g., indexing beyond the end of an array, 
>>>> dereferencing a
>>>> null pointer, etc.
>>>
>>> I agree. Stuff like the following is just "stupid":
>>>
>>>     int *p;
>>>
>>>     *p = 5;  //Undefined Behaviour
>>>
>> This is one thing, and in that case its really stupid, but, the same
>> behaviour can happen across longer code, with some function - calls
>> inside, AFAIK this code is also undefined:
>>
>> int my_int; // missing initialisation
>> cout << my_int << endl;
>>
>> Why is it impossible to let the compiler do the initialisation for 
>> me, I
>> have to do it anyway, either in my code, where I can leave it otu, 
>> or,
>> on the secure side, the compiler does tyhis thing for me.
> 
> Some compilers do warn you if you use uninitialized variables. That is 
> fine.

That is what I mean. Why not all? If I like to use uninitialized
variables, I can use them and I'm able to ignore or even supress the
warning.

But if I don't like them, but write code that uses them I've the
opportunity to get reid of them in my code, and yes, I don't liek them :-).

> One expert argument against having the compiler "fix" broken code, is 
> that the code is old C-style anyway. In C++ the rule was changed, so 
> you generally can delay the declaration of the variable until you have 
> its initial value available. That solves the problem.

I don't thik so :-). Not only old C - COde is affected by these
problems, also "new" C++ - code is affected, because it just hapen, if
you want or not, either if you are lazy or if you just miss one stupid
initialisazion :-(.


> Also, in non-broken code, zero initializing all variables at the point 
> of declaration and then assigning them later, would make the old C 
> code run slower when compiled as C++. Not the best marketing trick!


Sorry, in any case I have to write somehting before I read it or not?
And the biggest Problems ar not the loop - counters for for - loops.
What I mean are struct - mebers for example, why I'm forced to do the
inistalisazion for private - members to zero (in case of an int)?

>> Even if I do that, I can run into problems, think of 
>> std::list::front.
>> If the list is empyt everythign can happen, again the question, why 
>> not
>> pakking the code into the method. Why should the user must care 
>> about
>> the inetrnal state of the list, ind this example.
> 
> Why should the programmer be bothered with the correctness of his 
> program?  :-)

Why not :-)?

> 
>> he typemixing is another problem, that is solved by specific 
>> compilers,
>> they warn you at least, why not forbis some things, you all have 
>> called
>> stupid,if they are soo stupid?
> 
> This is all part of the C inheritance. The combined blessing and curse 
> of C++.

:-)

> There are several other languages designed to avoid these problems. 
> Can you name one? Why not? Were they not successful?

Which type of language to you mean? As powerful as C++ or some other
language? :-).

Best regards,
Nicolas

P.S. Yes I like C++ :-)

--
|     Nicolas Pavlidis       |       Elvis Presly:          |
|   Student of SE  & KM      |      "Into the goto"         |
|  pavnic@sbox.tugraz.at     |       ICQ #320057056         |
| ------------University of Technology, Graz-----------------

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



