473,563 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

This is ridiculous!

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

void FunctionThatMod ifies(std::stri ng &a)
{
a = "You've been modified.";
}
int main()
{
std::string const a("Untouchable. ");
std::string &b = a; //Actually compiles with error!
FunctionThatMod ifies(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
Mar 4 '06
50 2689
* 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?
Mar 7 '06 #11
"Default User" <de***********@ yahoo.com> wrote in message
news:47******** ****@individual .net...
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?
Mar 7 '06 #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?
Mar 7 '06 #13
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.
Mar 7 '06 #14
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.
Mar 7 '06 #15
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.
Mar 7 '06 #16

"Alf P. Steinbach" <al***@start.no > skrev i meddelandet
news:47******** ****@individual .net...

"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
Mar 7 '06 #17
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

Mar 7 '06 #18
Jim Langston wrote:
"Default User" <de***********@ yahoo.com> wrote in message
news:47******** ****@individual .net...
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
Mar 7 '06 #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?
Mar 7 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
7731
by: Vamsi Mudrageda | last post by:
I am kind of new to Python, and after trying and using wxPython, I found it kind of lacking in easy-to-read documentation, speed at loading, and GUI response-time. So I am looking for an another GUI toolkit that is cross-platform for Python, and am leaning toward PyQt (PyGTK is kind of dull looking in comparison). Unfortunately, although...
52
6271
by: Vladimir Grul | last post by:
Hello, I have a class member function declared as class some_class { .... virtual int call(void); }; Can I use this-> inside the function body?
4
2149
by: Schraalhans Keukenmeester | last post by:
I have no clue why below code (found it somewhere and altered it a wee bit to my needs) will run without problem in both IE and Mozilla FireFox 1.0 but in the latter it takes up close to 100% cpu. It does check for type of browser, and indeed all works fine apart from that ridiculous amount of cpu taken. If you want to see if it does so in...
23
355
by: Darklight | last post by:
Question taken from a book Write a function that accepts two strings. Use the malloc() function to allocate enough memory to hold two strings after they have been concatenated(linked). Return a pointer to this new string. /* STRCAT1.C PROGRAM TO LINK TWO STRINGS TOGETHER */ #include<stdio.h> #include<string.h> #include<stdlib.h>
6
1438
by: RichG | last post by:
Does anyone remember this: Set datapath to "c:\somewhere" dNetUse "SomeTable" do some db work I asked the question a couple of days ago about how to attach a recordset or some form of data to a datagrid. I was using DAO. The lack of responses seemed to indicate that the question was out of the range of an answer. So I started looking...
171
4780
by: Raman | last post by:
Hi All, Here is a small Code, int main(void) { char *p=(char *) malloc(100); strcpy(p,"Test1234567890"); p=p+10; free(p);
30
508
by: Bill Reid | last post by:
#define MAX_VALUES 64 typedef struct { unsigned value_1; double value_2; double value_3; double value_4; } VALUES; typedef struct {
26
2818
by: Tomás Ó hÉilidhe | last post by:
Has anyone here got access to a ridiculous computer? Something like: CHAR_BIT == 9 PADDING_BITS(int) != 0 NUMBER_SYSTEM == SIGN_MAGNITUDE Null pointer bit pattern == All ones I'm writing some fully-portable code and would love to actually compile it for, and test it on, a very strange machine :-D
40
1970
by: Dave | last post by:
Hello, I'm teaching myself C by working my way through Steve Summit's tutorial (http://www.eskimo.com/~scs/cclass/cclass.html). In one of the questions (assignment 6, exercise 7), you have to write a function to read lines of arbitrary length from the command line, using malloc() and realloc() to allocate the necessary memory to hold the...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.