Strange Article on C++ casts

Discussion in 'C++' started by charlie, Jan 11, 2007.

  1. charlie

    charlie Guest


    I found an article on that talks about C++ casts

    The strange thing is the author says the following code will *not*
    double d=15.95;
    int n= static_cast<int> (d);

    and then he goes on to launch an attack against C++ casts. I can't see
    any reason why it shouldn't work and I tried with the MS and INTEL
    compilers and it compiles with nary a problem.

    Does anyone know what he's trying to say???

    charlie, Jan 11, 2007
    1. Advertisements

  2. I'm almost sure that the author tries to say: "C++ sucks, my favorite
    language is better"
    =?ISO-8859-15?Q?Juli=E1n?= Albo, Jan 11, 2007
    1. Advertisements

  3. charlie

    charlie Guest

    <grin> Well I would agree with you normally but he's a C++ guy. He's
    even served on the C++ standards committee. So it seems to be a strange
    mistake to make.
    charlie, Jan 11, 2007
  4. The code I actually found there was:

    int n;
    double d=15.95;
    int n= static_cast<int> (d);

    which won't compile as the variable n is defined twice. Having removed
    the first definition of n, the code compiles fine and does what it should.
    Obviously he doesn't know anything about them and won't bother to look
    into his textbook.
    Nope. Ignore him.

    Stuart Redmann, Jan 11, 2007
  5. charlie

    Ian Collins Guest

    That he doesn't know what he is talking about?
    Ian Collins, Jan 11, 2007
  6. charlie

    charlie Guest

    Ok great. I just got confused cause he's a published guy who worked on
    the the C++ standards committee. But I guess that don't necessarily
    mean much :)

    charlie, Jan 11, 2007
  7. charlie

    peter koch Guest

    charlie skrev:
    This snippet is perfectly ok, of course.
    I've read some of the stuff he wrote at informit, and there are several
    areas where stuff looked dubious (to be nice). To be nice to Danny
    Kalev, there are also some articles that are okay. I believe that
    getting on the C++ standards committee is possible even if you are a
    far way from being an expert.

    peter koch, Jan 11, 2007
  8. charlie

    Pete Becker Guest

    All you have to do is pay INCITS for the privelege. There are many
    silent members.


    -- Pete
    Roundhouse Consulting, Ltd. (
    Author of "The Standard C++ Library Extensions: a Tutorial and
    Reference." (
    Pete Becker, Jan 11, 2007
  9. charlie

    peter koch Guest

    Pete Becker skrev:
    I expected something in that direction. How much money are we talking

    peter koch, Jan 11, 2007
  10. charlie

    Pete Becker Guest

    Currently, $800 per year. And I should have mentioned that INCITS is the
    US organization. Other countries organize things differently.


    -- Pete
    Roundhouse Consulting, Ltd. (
    Author of "The Standard C++ Library Extensions: a Tutorial and
    Reference." (
    Pete Becker, Jan 11, 2007

  11. We're all gonna die! Bwahaaaaa... ;)
    Gernot Frisch, Jan 11, 2007
  12. charlie

    peter koch Guest

    charlie skrev:
    I've been digging some more and found that he is an author of "The
    ANSI/ISO C++ Professional Programmer's Handbook" which at was
    reviewed as "Not recommended". Francis Glassborow begins his review
    "I wish the publishers had not stated that the author is a member of
    the ISO/ANSI C++ Standards Committees as it lends more authority to his
    work than it deserves. To the best of my knowledge the author has never
    attended a meeting of WG21 & J16. That is not to say that there is no
    justification for the statement. Kalev is listed as an observer and is
    entitled to participate in any of the C++ Standards reflectors that he
    wishes to, however his is not a name that springs to mind as an active
    participant (I do take almost all the C++ Standards reflectors and
    think I am reasonably familiar with the active participants)."
    The review can be found at

    peter koch, Jan 11, 2007
  13. My mistake, I blindly assumed it was some type of joke and don't clicked the
    url, sorry.
    =?ISO-8859-15?Q?Juli=E1n?= Albo, Jan 11, 2007
  14. charlie

    Grizlyk Guest

    peter koch ÐÉÓÁÌ(Á):
    "he shows that he does not understand the full method because he
    provides inline definitions (not just declarations) for the _private_
    access copy constructor and assignment operator"

    What's ugly wrong with definitions of copy constructor and assignment
    operator? They can be called in some cases by the object itself and
    what the dangerous?
    Grizlyk, Jan 14, 2007
  15. charlie

    peter koch Guest

    Grizlyk skrev:
    If you want to disable e.g. copy constructing, this is defined by
    having the constructor private and without an implementation:
    myclass(myclass const& );

    and not as was apparantly done give it a body:
    myclass(myclass const& ) {}

    peter koch, Jan 14, 2007
  16. charlie

    Grizlyk Guest

    Are you shure, the compiler will not request (as error or warning) to
    define "myclass(myclass const& )"? It is good stuff, but as i can
    rememver, in old compilers were troubles with it (errors or warnings),
    i am not shure.
    No, not of course, do like this:
    myclass(myclass const& )throw(Myerror&) { throw Terr_private(
    typeid(*this).name() ); }
    Grizlyk, Jan 14, 2007
  17. charlie

    peter koch Guest

    Grizlyk skrev:
    Yes I am sure. What old compilers did or did not is irrelevant here.
    That can never be correct. If anything, an abort is in place.

    peter koch, Jan 14, 2007
  18. charlie

    Grizlyk Guest

    What does it ("If anything, an abort is in place") mean? Sorry, I can
    not translate it and understand.
    If no explanaition exist, I silently will ignore the opinion, for it
    contradicts my observations :)

    1. I am not "Danny Kalev".
    2. I am not going to buy his book now or in future.

    But the notes of "Francis Glassborow" here

    looks like personal attack. "he is just not with Us" - sad "Francis
    Glassborow" with long explanations. In general it is not enough to be

    I think, that book about details of C++ must be written by C++ expert.
    In order to show, that "Danny Kalev" is not, "Francis Glassborow" can
    just project the list of many undiscussable hard errors in the book
    instead of "he was invisible on our meetings".

    There are tons of thrash, named as "became C++ expert for one our" or
    "take our beer, wait just twenty years and you are C++ expert now". It
    is possible, some of them were written by people from "C++ Standards
    Committees" :)

    If the "comettee" does not agreed with the ideas of the book in general
    or in concretes cases,
    the comettee even can gather and make issue of the note, if "comettee"
    may do it and it is important.

    If the "Francis Glassborow" care only of honor of the comettee as
    private man, he just can say, that ideas of
    any private member of "comettee" can not be treated even as unofficial
    opinion of the "comettee",
    and always better give list of errors.
    Grizlyk, Jan 15, 2007
  19. charlie

    peter koch Guest

    Grizlyk skrev:
    It simply means that if a class is not copy-constructible, you should
    not write a copy constructor. Writing a copy constructor that throws is
    simply wrong: C++ exceptions are not for programming errors.
    My (silly) suggestion to call abort was meant to be used in the
    unlikely event someone should stumble over a compiler where you were
    forced to implement the copy-constructor. But I've never seen or heard
    about such a compiler, and considering the trickery involved in
    implementing such a beast and the problem to find any real codebase
    that would compile, I must say I find that most unlikely to ever
    Glassborow did just that. There were three examples of C++ ignorance in
    a one page long review.
    Actually, Danny Kalev was such a member: as noted elsewhere in this
    thread it only requires paying a modest fee to your national standard
    organisation, at least in the US. While other members might also write
    bad books, chances are that they will not make such obvious errors as
    generously provided by Kalev.
    This is not a matter of taste or agreement. The book is simply
    objectively wrong and thats it.

    peter koch, Jan 15, 2007
  20. charlie

    Grizlyk Guest

    I can not prove my opinion, that "some old compilers required all
    constructors defined if they are declared", but I can say, that the
    evil tidings "to define private member as throw error" among me is
    existing for my classes at least for 10 years (from 2000 year). Yes, I
    do not use C++ intensively for all the years (there was many years,
    when i never see not a line of C++ code), but after the time I forgot
    the cause to do like this, just copying it :)

    It is possible, "private member as throw error" is ancient error, but
    agree, so longlife invisible "error" easy prove, that "error" is not
    error. Really, it is does not metter for practiacal use, "to define
    private member as throw error" or "to not define private member" (i see
    differences), but yes, last is more smart solution and in general
    better. I feel a reason to change my tradition :)

    The worst way is "defining private member as empty code" or "defining
    private member as calling exit() or abort()": both is ugly wrong.
    I saw the examples, but all of them can be easy treated as "does not
    matter" and Glassborow objections _looks_ just like "game with words".
    I agree, that man (Danny Kalev) who describe standard must be more
    pedantic than pedanctic, but can repeat again - Glassborow was not
    convincing, he just not listed very ugly obvious errors.

    All Glassborow examples less than 5% of size of his note, other about
    him and comitee. Most engeneers ignore results, if value is less than
    10% of other value :) All Glassborow examples is strange shortest parts
    of unknown code, without any sence and original context.
    It is possible, i do not see the book. And i am not going to do it.
    Grizlyk, Jan 16, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.