Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6099

Re: Casting template argument

From Pete Becker <pete@versatilecoding.com>
Organization Roundhouse Consulting, Ltd.
Newsgroups comp.lang.c++
Date 2011-06-02 10:40 -1000
Message-ID <2011060210404116688-pete@versatilecodingcom> (permalink)
References <4de78326$0$6554$9b4e6d93@newsspool4.arcor-online.net> <4de7f3f0$0$7624$9b4e6d93@newsspool1.arcor-online.net>
Subject Re: Casting template argument

Show all headers | View raw


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)

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Casting template argument Marcel Müller <news.5.maazl@spamgourmet.org> - 2011-06-02 14:33 +0200
  Re: Casting template argument Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-02 10:17 -0400
    Re: Casting template argument Marcel Müller <news.5.maazl@spamgourmet.org> - 2011-06-02 22:10 +0200
      Re: Casting template argument Pete Becker <pete@versatilecoding.com> - 2011-06-02 10:21 -1000
        Re: Casting template argument Marcel Müller <news.5.maazl@spamgourmet.org> - 2011-06-02 22:34 +0200
          Re: Casting template argument Pete Becker <pete@versatilecoding.com> - 2011-06-02 10:40 -1000

csiph-web