From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!irazu.switch.ch!switch.ch!news.grnet.gr!newsfd02.forthnet.gr!not-for-mail From: Ioannis Vranos Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Class hierarchy of exceptions (Ada, C++) Date: Wed, 30 Mar 2005 15:22:18 +0300 Organization: FORTHnet S.A., Atthidon 4, GR-17671 Kalithea, Greece, Tel: +30 2109559000, Fax: +30 2109559333, url: http://www.forthnet.gr Message-ID: <1112185337.193940@athnrd02> References: NNTP-Posting-Host: athnrd02.forthnet.gr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: athprx02.forthnet.gr 1112185337 31671 193.92.150.73 (30 Mar 2005 12:22:17 GMT) X-Complaints-To: abuse@forthnet.gr NNTP-Posting-Date: Wed, 30 Mar 2005 12:22:17 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en In-Reply-To: Cache-Post-Path: newsfd02!unknown@ppp13-adsl-131.ath.forthnet.gr Xref: g2news1.google.com comp.lang.ada:10150 comp.lang.c++:47954 comp.realtime:1829 comp.software-eng:5465 Date: 2005-03-30T15:22:18+03:00 List-Id: Tapio Kelloniemi wrote: > STL is safer, but it cannot always be > used (eg. when interfacing to foreign code). An example? > Another example: > > int* f() > { > int i = 3; > int& l = *(new int); > > l = i; > int* p = &i; // Should be int* p = &l; > > return p; > } > > int main() > { > int* p = f(); > *p = 4; > return 0; > } > > # g++ -Wall -o temp temp.cc > # > > Not even a warning and the program does not crash on my system! Valgrind > revealed the error (and thought it was a G++ bug). Strictly speaking one shouldn't use such variable names. However this is not easy to check all those things. C++ aims to be an *enabling* language. For example one could have written the following code for a system: int* f() { // For setting panel indication. int *p =reinterpret_cast (0x148); // For reading external thermometer volatile const int *r= reinterpret_cast(329); // ... return p; } int main() { int* p = f(); *p = 4; return 0; } -- Ioannis Vranos http://www23.brinkster.com/noicys