Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > This is ridiculous!

Reply
Thread Tools

This is ridiculous!

 
 
Tomás
Guest
Posts: n/a
 
      03-04-2006
#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
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      03-04-2006
* 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?
 
Reply With Quote
 
 
 
 
Pete Becker
Guest
Posts: n/a
 
      03-05-2006
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.
 
Reply With Quote
 
Tomás
Guest
Posts: n/a
 
      03-05-2006

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



God damn typo. Should've written:

Actuall compiles *without* error!


-Tomás
 
Reply With Quote
 
Joe Van Dyk
Guest
Posts: n/a
 
      03-06-2006
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"?

 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      03-07-2006
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

 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      03-07-2006
"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!


 
Reply With Quote
 
Jerry Coffin
Guest
Posts: n/a
 
      03-07-2006
In article <(E-Mail Removed)>, 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.
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      03-07-2006
* 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?
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      03-07-2006
* 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?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments