473,698 Members | 2,153 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 2717
* Bo Persson:
"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. :-)


The standard simply assumes the reader is competent enough to understand
what's meant by e.g. "translatio n" 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?
Mar 7 '06 #21
* Pete Becker:
The standard does not require "error" messages nor "warnings".
That is literally correct, it requires diagnostics.

It does not require that anything not compile.
That is literally correct, the word "compiler" occured just once in an
early version, then was removed.

The only requirement on
ill-formed programs is that the compiler issue a diagnostic.


And I think that is literally correct, too.

But this feels like talking to a robot.

All your comments are completely irrelevant. Do you not understand what
"error" means? Do you not understand the 135 relevant usages of that
word in the standard? Do you not understand what the OP asked?

--
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 #22
Bo Persson wrote:

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.


Or do whatever the implementor decides. The requirement for an
ill-formed program is only that the compiler issue a diagnostic. That's
the hook for implementation-specific extensions: the compiler issues a
diagnostic then handles the extension.

--

Pete Becker
Roundhouse Consulting, Ltd.
Mar 7 '06 #23
Alf P. Steinbach wrote:

All your comments are completely irrelevant. Do you not understand what
"error" means? Do you not understand the 135 relevant usages of that
word in the standard? Do you not understand what the OP asked?

To repeat the original question, which may have gotten lost in the noise:
Compiler gives me a warning. I think it should give me a downright error,
and I want it to give me a downright error.


Seems quite clear: he's disappointed that the compiler only gave a
warning message, he wants it to give an error message and decline to
compile the program. There is no such requirement in the language
definition. In particular, "It should not compile" is wrong.

--

Pete Becker
Roundhouse Consulting, Ltd.
Mar 7 '06 #24
* Pete Becker:
Alf P. Steinbach wrote:

All your comments are completely irrelevant. Do you not understand
what "error" means? Do you not understand the 135 relevant usages of
that word in the standard? Do you not understand what the OP asked?


To repeat the original question, which may have gotten lost in the noise:
Compiler gives me a warning. I think it should give me a downright
error, and I want it to give me a downright error.


Seems quite clear: he's disappointed that the compiler only gave a
warning message, he wants it to give an error message and decline to
compile the program. There is no such requirement in the language
definition.


In one sense you're right about that.

Formally, a C++ compiler is free to compile ill-formed Visual Basic
source code, or a letter to mom.

As long as it issues some diagnostic, which could be as subtle as doing
absolutely nothing (the diagnostic in this case being the absence of a
toggling of the NumLock LED indicator on the keyboard, for example).
In particular, "It should not compile" is wrong.

Nope.

You have substituted a context where you interpret the question as to
what the standard literally requires of a compiler, which is nothing,
since the standard does not mention compilers; in particular, it does
not define that they are C++ implementations .

But let's assume that a compiler (plus runtime support, etc.) is a C++
implementation, and not just an implementation, but a conforming one.

Can that compiler accept an ill-formed program text? Yes, formally it
can, and you have stated that yourself. Can it decline to accept a
well-formed program text? Yes, formally it can, it can say, by not
blinking the keyboard's NumLock LED, "Sorry, I ran out of memory", or
whatever (the standard uses language such as "within its resource
limits" to cater for this possibility), and also because when you follow
requirements down into their most basic details, you must always find
them expressed using words that are not themselves defined by the
standard. Does the standard then place any real hard constraints on
this conforming implementation? Nope, none whatsoever.

In the literally formal, the viewpoint you have chosen, there is
therefore no such thing as a C++ implementation, because it could be
anything, and still literally satisfy the standard's rules.

Therefore that is /meaningless/.
--
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 #25
Alf P. Steinbach wrote:

Sigh. The original question asked, in part,
Firstly, does the Standard say whether this should generate a warning or an error?


And you replied to that with:

An error.


Where in the standard did you find this?

--

Pete Becker
Roundhouse Consulting, Ltd.
Mar 7 '06 #26
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!


You know that an implementation has output messages, and that not all
of them are necessarily considered diagnostics.

The implementation defines which messages are diagnostics, which means
that there has to be an accompanying document that lists them or
indicates how they can be recognized from among other messages.

When the standard requires a situation to be diagnosed, one of these
messages must appear from the implementation.

Mar 7 '06 #27
* Pete Becker:
Alf P. Steinbach wrote:

Sigh. The original question asked, in part,
Firstly, does the Standard say whether this should generate a warning
or an error?


And you replied to that with:

An error.


Where in the standard did you find this?


By now you should have understood what "error" means, as the word is
used in the standard and by the OP.

But I'll explain it once more: it means "ill-formed".

Regarding the standard's rules for cv-qualification and conversions, I
don't think it's true that you're unable to find them. I don't think
your question is truthful, I think it is argumentative. However, for
the sake of discussion I'll /assume/ that your question is truthful,
that you really want a little help here.

A quick search now yielded that a very similar example is given at the
end §8.5.3/5 with the explanation "error: type qualifiers dropped". You
should understand that I did not consult the standard regarding the
original question, and in particular I did not check out this example,
which I now have provided on your direct request. The question was and
is basic, trivial, and it's just coincidental that this example exists.

But in spite of my assumption above, I'm sure that if you respond it
will be along the lines of examples in the standard not being normative,
or some such context-switching and literal-minded irrelevant argument,
at a stroke rendering all 135 examples meaningless to win a discussion.

--
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 #28
Alf P. Steinbach wrote:
* Pete Becker:
Alf P. Steinbach wrote:

Sigh. The original question asked, in part,
Firstly, does the Standard say whether this should generate a
warning or an error?
And you replied to that with:

An error.

Where in the standard did you find this?

By now you should have understood what "error" means, as the word is
used in the standard and by the OP.


Again: the OP asked whether this should "generate a warning or an error".
But I'll explain it once more: it means "ill-formed".
I see. So your answer to the question whether that should "generate a
warning or an error" is that it should "generate an ill-formed".

Regarding the standard's rules for cv-qualification and conversions, I
don't think it's true that you're unable to find them.


I didn't say anything about the rules for cv-qualification. I asked you
where you found a requirement to issue an error message rather than a
warning, since that's what the question explicitly asked about.
--

Pete Becker
Roundhouse Consulting, Ltd.
Mar 7 '06 #29
* Pete Becker:
Alf P. Steinbach wrote:
* Pete Becker:
Alf P. Steinbach wrote:

Sigh. The original question asked, in part,

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

And you replied to that with:
An error.
Where in the standard did you find this?

By now you should have understood what "error" means, as the word is
used in the standard and by the OP.


Again: the OP asked whether this should "generate a warning or an error".
But I'll explain it once more: it means "ill-formed".


I see. So your answer to the question whether that should "generate a
warning or an error" is that it should "generate an ill-formed".


Is that a question?

Regarding the standard's rules for cv-qualification and conversions, I
don't think it's true that you're unable to find them.


I didn't say anything about the rules for cv-qualification. I asked you
where you found a requirement to issue an error message rather than a
warning, since that's what the question explicitly asked about.


It might seem, from this posting, that you still haven't understood what
"error" means.

But you snippped the standard's example I gave in response to your
question, which to my mind means you now really do understand what
"error" means as used in the standard and by the OP, and that you are
now just obstinately argumentative.

With "error" meaning "ill-formed", the meaning of "warning" is easy to
deduce, given the definition of "diagnostic ": it is the set of other
possible diagnostics. Current compilers label them as warnings. Given
that, you don't need to deduce the meaning: you should already know it.

--
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 #30

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

Similar topics

35
7753
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 TrollTech says Qt is cross-platform, its license strategy has me a bit confused. So here is to...
52
6309
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
2159
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 your firefox/xp too, it's embedded in my homepage (www.westerterp.com) Can anyone explain why...
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
1443
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 around to find out what does this datagrid want that the datagrid in VB5 did not need. It looked...
171
4875
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
2839
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
1986
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 lines. I came up with this: char *getline(char *line) {
0
8674
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9026
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7723
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.