Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 02 Jun 2011 15:40:41 -0500 From: Pete Becker Organization: Roundhouse Consulting, Ltd. Newsgroups: comp.lang.c++ Date: Thu, 2 Jun 2011 10:40:41 -1000 Message-ID: <2011060210404116688-pete@versatilecodingcom> References: <4de78326$0$6554$9b4e6d93@newsspool4.arcor-online.net> <4de7f3f0$0$7624$9b4e6d93@newsspool1.arcor-online.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Casting template argument User-Agent: Unison/2.1.4 Lines: 43 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-qAV5gsr6NPkB8yrbG8eqF5ksUnxDsO+RKv2UWWg2wJfUIWtm+xQEr2zffAOQJV34td9phe3kn1apjN0!z0eQKmRQZEytweSV/8x7oZifI4ovqyl8Xow8h20XRH9oNGlIRLkWWaUGWLEPuXktqh+EDnk= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2910 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:6099 On 2011-06-02 10:34:55 -1000, Marcel Müller said: > On 02.06.11 22.21, Pete Becker wrote: >>> So what is >>> UB in general is not necessarily UB on this specific platform. >> >> Undefined behavior arises from valid code constructs for which the C++ >> language definition does not impose any requirements. That doesn't >> depend in any way on the compiler that you're using or on the target >> platform. > > This is UB with respect to the C++ language. The documentation of a > specific compiler may define the behavior in cases where the C++ > language does not. > Passing pointer arguments is exactly defined on my platform. So the > result of my cast is defined behavior, by all means with the three > compilers that are supported (IBM, gnu, Watcom). Thus utterly missing the point. Again: the C++ langauge definition does not tell you what happens when you do this, so the behavior is undefined. > >> The *consequences* of using code whose behavior is undefined depend on >> the compiler and the platform. > > Some code behavior is even undefined if you exactly know the platform > and the compiler. E.g. accessing objects after they have been deleted. > Code whose behavior is undefined has undefined behavior *even if* you exactly know the platform and the compiler, and *even if* the compiler defines what happens. Undefined behavior is about what the C++ standard requires, not about what a particular compiler does or doesn't do. In particular, undefined behavior is not a synonym for "something bad will probably happen". -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book)