473,624 Members | 2,281 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 #1
50 2707
* 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?
Mar 4 '06 #2
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.
Mar 5 '06 #3
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."

--

Pete Becker
Roundhouse Consulting, Ltd.
Mar 5 '06 #4
std::string &b = a; //Actually compiles with error!

God damn typo. Should've written:

Actuall compiles *without* error!
-Tomás
Mar 5 '06 #5
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"?

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

Mar 7 '06 #7
"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!
Mar 7 '06 #8
In article <47************ @individual.net >, 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.
Mar 7 '06 #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?
Mar 7 '06 #10

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

Similar topics

35
7747
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
6295
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
2154
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
1440
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
4838
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
2830
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
1983
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
8177
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
8681
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
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...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5570
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
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
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.