This is ridiculous!

Discussion in 'C++' started by Tomás, Mar 4, 2006.

  1. Tomás

    Tomás Guest

    #include <string>
    #include <iostream>
    using std::cout;
    using std::endl;

    void FunctionThatModifies(std::string &a)
    {
    a = "You've been modified.";
    }


    int main()
    {
    std::string const a("Untouchable.");


    std::string &b = a; //Actually compiles with error!


    FunctionThatModifies(b);


    std::cout << b;
    }


    Compiler gives me a warning. I think it should give me a downright error,
    and I want it to give me a downright error.

    Firstly, does the Standard say whether this should generate a warning or
    an error?

    Secondly, do compilers have an option whereby you can make it give an
    error? If so, I'll be using it.


    -Tomás
    Tomás, Mar 4, 2006
    #1
    1. Advertising

  2. * Tomás:
    > std::string const a("Untouchable.");
    > std::string &b = a; //Actually compiles with error!
    >
    > Compiler gives me a warning. I think it should give me a downright error,
    > and I want it to give me a downright error.


    It should not compile.


    > Firstly, does the Standard say whether this should generate a warning or
    > an error?


    An error.


    > Secondly, do compilers have an option whereby you can make it give an
    > error? If so, I'll be using it.


    Compiler options are compiler-specific; check your compiler's help text
    and/or documentation.


    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Mar 4, 2006
    #2
    1. Advertising

  3. Tomás

    Pete Becker Guest

    Tomás wrote:
    >
    >
    > Compiler gives me a warning. I think it should give me a downright error,
    > and I want it to give me a downright error.
    >
    > Firstly, does the Standard say whether this should generate a warning or
    > an error?


    It requires "a diagnostic." The standard doesn't talk about warnings and
    errors.

    >
    > Secondly, do compilers have an option whereby you can make it give an
    > error? If so, I'll be using it.


    Many do.

    --

    Pete Becker
    Roundhouse Consulting, Ltd.
    Pete Becker, Mar 5, 2006
    #3
  4. Tomás

    Tomás Guest


    > std::string &b = a; //Actually compiles with error!



    God damn typo. Should've written:

    Actuall compiles *without* error!


    -Tomás
    Tomás, Mar 5, 2006
    #4
  5. Tomás

    Joe Van Dyk Guest

    On Sun, 05 Mar 2006 09:37:52 -0500, Pete Becker wrote:

    > Alf P. Steinbach wrote:
    >
    >
    >>
    >>> Firstly, does the Standard say whether this should generate a warning
    >>> or an error?

    >>
    >>
    >> An error.
    >>

    >
    > The Standard requires "a diagnostic." It does not specify the form or
    > the consequences of that diagnostic, and it does not distinguish between
    > a "warning" and an "error."


    What is "a diagnostic"?
    Joe Van Dyk, Mar 6, 2006
    #5
  6. Tomás

    Default User Guest

    Joe Van Dyk wrote:

    > On Sun, 05 Mar 2006 09:37:52 -0500, Pete Becker wrote:
    >
    > > Alf P. Steinbach wrote:
    > >
    > >
    > >>
    > >>> Firstly, does the Standard say whether this should generate a

    > warning >>> or an error?
    > >>
    > >>
    > >> An error.
    > >>

    > >
    > > The Standard requires "a diagnostic." It does not specify the form
    > > or the consequences of that diagnostic, and it does not distinguish
    > > between a "warning" and an "error."

    >
    > What is "a diagnostic"?


    From the standard, under Terms and definitions:

    1.3.2 diagnostic message
    a message belonging to an implementation-defined subset of the
    implementation's output messages.



    Brian
    Default User, Mar 7, 2006
    #6
  7. Tomás

    osmium Guest

    "Default User" writes:

    >> What is "a diagnostic"?

    >
    > From the standard, under Terms and definitions:
    >
    > 1.3.2 diagnostic message
    > a message belonging to an implementation-defined subset of the
    > implementation's output messages.


    There must be a word for that. You actually know *less* after reading the
    definition than you did before you read it!
    osmium, Mar 7, 2006
    #7
  8. Tomás

    Jerry Coffin Guest

    In article <>, r124c4u102
    @comcast.net says...

    [ ... ]

    > There must be a word for that. You actually know *less* after reading the
    > definition than you did before you read it!


    I don't agree that's the case here, but where it is I
    think "Schildtism" would be an appropriate term.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
    Jerry Coffin, Mar 7, 2006
    #8
  9. * Pete Becker:
    > Alf P. Steinbach wrote:
    >>
    >>> Firstly, does the Standard say whether this should generate a warning
    >>> or an error?

    >>
    >> An error.

    >
    > The Standard requires "a diagnostic." It does not specify the form or
    > the consequences of that diagnostic, and it does not distinguish between
    > a "warning" and an "error."


    I didn't see this erronous nit-picking posting when you made it, but
    I'll clear that up anyway.

    The 1998 C++ standard contains 135 instances of "error" being used as a
    synonym for "ill-formed".

    I.e., you chose the wrong term to look up, you should have looked up
    "ill-formed", not "diagnostic".

    "Error" and "warning" are however not terms _defined_ by the standard.
    They are terms used by actual compilers. "Error" means the program does
    not compile, and "warning" means that at least that part of it compiles,
    but with some probably dubious construct that may not do what you intended.

    Just to repeat: the standard's official term corresponding to "error", a
    program that does not compile, is not "diagnostic", it is "ill-formed"


    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Mar 7, 2006
    #9
  10. * Pete Becker:
    > Tomás wrote:
    >>
    >>
    >> Compiler gives me a warning. I think it should give me a downright
    >> error, and I want it to give me a downright error.
    >>
    >> Firstly, does the Standard say whether this should generate a warning
    >> or an error?

    >
    > It requires "a diagnostic." The standard doesn't talk about warnings and
    > errors.


    It really does.

    The 1998 C++ standard contains 135 instances of "error" being used as a
    synonym for "ill-formed".

    It also contains 1 usage of "warning", exemplifying that that is a term
    it is assumed that readers of the standard should understand.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Mar 7, 2006
    #10
  11. Tomás

    Jim Langston Guest

    "Default User" <> wrote in message
    news:...
    > Joe Van Dyk wrote:
    >
    >> On Sun, 05 Mar 2006 09:37:52 -0500, Pete Becker wrote:
    >>
    >> > Alf P. Steinbach wrote:
    >> >
    >> >
    >> >>
    >> >>> Firstly, does the Standard say whether this should generate a

    >> warning >>> or an error?
    >> >>
    >> >>
    >> >> An error.
    >> >>
    >> >
    >> > The Standard requires "a diagnostic." It does not specify the form
    >> > or the consequences of that diagnostic, and it does not distinguish
    >> > between a "warning" and an "error."

    >>
    >> What is "a diagnostic"?

    >
    > From the standard, under Terms and definitions:
    >
    > 1.3.2 diagnostic message
    > a message belonging to an implementation-defined subset of the
    > implementation's output messages.


    Umm.. if I'm reading htat right, it basically says that a diagnostic message
    is an output message. Not exactly specific is it?
    Jim Langston, Mar 7, 2006
    #11
  12. * Jim Langston:
    > * "Default User":
    >>
    >> 1.3.2 diagnostic message
    >> a message belonging to an implementation-defined subset of the
    >> implementation's output messages.

    >
    > Umm.. if I'm reading htat right, it basically says that a diagnostic message
    > is an output message. Not exactly specific is it?


    "diagnostic" isn't the part being defined, you're assumed to understand
    what "diagnostic" means. What's defined, in a badly worded way, is that
    a compiler ("translator" in the standard's terminology) is allowed to
    output other messages than those corresponding to "requires a
    diagnostic", including non-diagnostic messages. If you go the route of
    trying to find definitions of common-sense terms you won't find a
    definition of "translator" either, although the term is used.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Mar 7, 2006
    #12
  13. Tomás

    Pete Becker Guest

    Alf P. Steinbach wrote:
    >
    > Just to repeat: the standard's official term corresponding to "error", a
    > program that does not compile, is not "diagnostic", it is "ill-formed"
    >


    The standard does not require that anything not compile. An ill-formed
    program requires a diagnostic. Nothing more.

    --

    Pete Becker
    Roundhouse Consulting, Ltd.
    Pete Becker, Mar 7, 2006
    #13
  14. Tomás

    Pete Becker Guest

    Alf P. Steinbach wrote:

    > * Pete Becker:
    >
    >> Tomás wrote:
    >>
    >>>
    >>>
    >>> Compiler gives me a warning. I think it should give me a downright
    >>> error, and I want it to give me a downright error.
    >>>
    >>> Firstly, does the Standard say whether this should generate a warning
    >>> or an error?

    >>
    >>
    >> It requires "a diagnostic." The standard doesn't talk about warnings
    >> and errors.

    >
    >
    > It really does.
    >
    > The 1998 C++ standard contains 135 instances of "error" being used as a
    > synonym for "ill-formed".


    Nevertheless, it does not require "a warning" nor "an error" (not even
    "a downright error") as used in the original message. Context matters.

    >
    > It also contains 1 usage of "warning", exemplifying that that is a term
    > it is assumed that readers of the standard should understand.
    >


    The standard does not require "error" messages nor "warnings". It does
    not require that anything not compile. The only requirement on
    ill-formed programs is that the compiler issue a diagnostic.

    --

    Pete Becker
    Roundhouse Consulting, Ltd.
    Pete Becker, Mar 7, 2006
    #14
  15. Tomás

    Pete Becker Guest

    Jim Langston wrote:
    >
    > Umm.. if I'm reading htat right, it basically says that a diagnostic message
    > is an output message. Not exactly specific is it?
    >


    Nope. Could be text, could be beeps from the speaker, could be flashing
    the screen. It's up to the implementation.

    --

    Pete Becker
    Roundhouse Consulting, Ltd.
    Pete Becker, Mar 7, 2006
    #15
  16. Tomás

    Bo Persson Guest

    "Alf P. Steinbach" <> skrev i meddelandet
    news:...
    >
    > "Error" and "warning" are however not terms _defined_ by the
    > standard. They are terms used by actual compilers. "Error" means
    > the program does not compile, and "warning" means that at least that
    > part of it compiles, but with some probably dubious construct that
    > may not do what you intended.


    There is no requirement to compile the program, it could be
    interpreted. :)

    >
    > Just to repeat: the standard's official term corresponding to
    > "error", a program that does not compile, is not "diagnostic", it is
    > "ill-formed"
    >


    Even if there is an "error" the translator can issue its diagnostic
    (required), see that it was an obvious typo, and then continue with
    the translation.


    Bo Persson
    Bo Persson, Mar 7, 2006
    #16
  17. Tomás

    Default User Guest

    osmium wrote:

    > "Default User" writes:
    >
    > > > What is "a diagnostic"?

    > >
    > > From the standard, under Terms and definitions:
    > >
    > > 1.3.2 diagnostic message
    > > a message belonging to an implementation-defined subset of the
    > > implementation's output messages.

    >
    > There must be a word for that. You actually know less after reading
    > the definition than you did before you read it!


    Actually, it lets you know you all you're going to be able to tell
    about it. A diagnostic is an output message. It's
    implementation-defined, which means that the implementation must
    document the messages. That's all you can count on. There's no talk of
    "warnings" or "errors", no indication that compilation must continue or
    stop.




    Brian
    Default User, Mar 7, 2006
    #17
  18. Tomás

    Default User Guest

    Jim Langston wrote:

    > "Default User" <> wrote in message
    > news:...
    > > Joe Van Dyk wrote:


    > > > What is "a diagnostic"?

    > >
    > > From the standard, under Terms and definitions:
    > >
    > > 1.3.2 diagnostic message
    > > a message belonging to an implementation-defined subset of the
    > > implementation's output messages.

    >
    > Umm.. if I'm reading htat right, it basically says that a diagnostic
    > message is an output message. Not exactly specific is it?


    The key is that it is implementation-defined. The implementation is
    required to document the diagostics. Of course, that doesn't mean that
    they have to be meaningful (and we've all seen some pretty obscure or
    misleading messages). Printing, "your code sucks and so do you" for
    every diagnostic would be perfectly within the standard.



    Brian
    Default User, Mar 7, 2006
    #18
  19. * Pete Becker:
    > Alf P. Steinbach wrote:
    >>
    >> Just to repeat: the standard's official term corresponding to "error",
    >> a program that does not compile, is not "diagnostic", it is "ill-formed"
    >>

    >
    > The standard does not require that anything not compile. An ill-formed
    > program requires a diagnostic. Nothing more.


    That is correct, at last.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Mar 7, 2006
    #19
  20. * Bo Persson:
    > "Alf P. Steinbach" <> skrev i meddelandet
    > news:...
    >> "Error" and "warning" are however not terms _defined_ by the
    >> standard. They are terms used by actual compilers. "Error" means
    >> the program does not compile, and "warning" means that at least that
    >> part of it compiles, but with some probably dubious construct that
    >> may not do what you intended.

    >
    > There is no requirement to compile the program, it could be
    > interpreted. :)


    The standard simply assumes the reader is competent enough to understand
    what's meant by e.g. "translation" and "error".


    >> Just to repeat: the standard's official term corresponding to
    >> "error", a program that does not compile, is not "diagnostic", it is
    >> "ill-formed"
    >>

    > Even if there is an "error" the translator can issue its diagnostic
    > (required), see that it was an obvious typo, and then continue with
    > the translation.


    Most compilers -- unfortunately -- do. If they hadn't they could
    have been superfast. The idea of continuing is some idiocy from the
    1950's that compiler writers haven't managed to rid themselves of.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Mar 7, 2006
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. license_rant_master
    Replies:
    37
    Views:
    1,784
  2. Nebojsa Topolscak
    Replies:
    3
    Views:
    555
    Jon Caldwell
    Jan 14, 2005
  3. Replies:
    17
    Views:
    776
  4. Rob
    Replies:
    6
    Views:
    386
    brucie
    Dec 18, 2003
  5. Tomás Ó hÉilidhe

    Access to a ridiculous computer? :-D

    Tomás Ó hÉilidhe, Jan 1, 2008, in forum: C Programming
    Replies:
    27
    Views:
    735
    Jean-Marc Bourguet
    Jan 14, 2008
Loading...

Share This Page