Re: The worst 'hello world' example ever written...

W

WW

Ron said:
And if the compiler does decide to accept ill-formed code, it still
is required to issue a "diagnostic."

That was in Herbs first post. And I did not want to overload his brain.
 
T

The_Sage

Reply to article by: "Attila Feher said:
Date written: Thu, 25 Sep 2003 11:18:42 +0300
MsgID:<[email protected]>
You need to learn to read.

No you do. The spec clearly stated that "...its type is implementation-defined"
and you failed to explain why IBM, MS, and Borland all implemented-defined void
main() and yet still claim to be ISO compliant. Or maybe it wasn't that you
failed, but that you dodged and evaded the issue because it exposes a gap in
your claim bigger than the gap between your ears?

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 
W

WW

The_Sage said:
No you do.

I did. So I *know*. You only whish.
The spec clearly stated that "...its type is
implementation-defined"

The spec clearly stated that it *must* return int, "otherwise its type is
implementation-defined".
and you failed to explain why IBM, MS, and Borland all
implemented-defined void main() and yet still claim to be
ISO compliant.

Herb Sutter explained it for you.
Or maybe it wasn't that you failed,

Excatly. You failed.
but that you dodged and evaded the issue because
it exposes a gap in your claim
bigger than the gap between your ears?

I have answered your stupid claims every time. You delete them from the
answer every time. You know you are wrong. Stop trolling.
 
T

The_Sage

Reply to article by: "WW said:
Date written: Fri, 26 Sep 2003 06:08:56 +0300
MsgID:<[email protected]>

Well?

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 
D

David B. Held

The_Sage said:
[...]
Well?

I have challenged you several times to show statements by any
of these organizations claiming that their compilers are 100%
conforming. Assuming that they are and then assuming that
any code they accept is conforming C++ is very much like
assuming that every car built by the Big Three is crash-proof,
and that any road you drive such a car on is also crash-proof,
because you drove a few cars on a few roads and didn't crash.
You start out with an incorrect assumption, and then throw in
a non-sequitur. Combine that with an inability to correctly
parse entire English sentences (perhaps they overload your
stack), and it's a wonder you can even tie your shoes in the
morning (though I wouldn't be suprised if you stick with sandals
or velcro straps).

Dave
 
A

Attila Feher

David B. Held wrote:
[SNIP]
morning (though I wouldn't be suprised if you stick with sandals
or velcro straps).

Hey! I have velcro straps! And sandals.

(Shoelaces somehow always break within a short time. Might be the hight of
my feet...)


#include <iostreams>
typedef int not_void;

not_void main() {
std::cout <<
"Having velcro straps and sandals"
" does not make you a moron." << // :)
std::endl;
}
 
N

Noah Roberts

Attila said:
David B. Held wrote:
[SNIP]
morning (though I wouldn't be suprised if you stick with sandals
or velcro straps).


Hey! I have velcro straps! And sandals.

I have velcro straps on my sandals :p I also only tie my shoes when the
undo themselves as I am too lazy to do it in the morning :p

NR
 
A

Andrew Koenig

Your interpretation of the standard is incorrect.
You mean, IBM, MS, Borland and other compiler manufacturer's
interpretation of the standard is incorrect.

No, I don't mean that. If I meant that, I would have said it.
Here is what the standard actually says:
Subclause 3.6.1, paragraph 2:
An implementation shall not predefine the `main' function.
This function shall not be overloaded. It shall have a return
type of type `int,' but otherwise its type is implementation-
defined. All implementations shall allow both of the following
definitions of `main':
int main() { /* ... */ }
and
int main(int argc, char* argv[]) { /* ... */ }
When the C++ standard uses the word ``shall'' in this way, it
expresses a requirement on programs that every standard-conforming
implementation is required to enforce, at least by producing a
diagnostic message (which might be only a warning) for any program
that does not meet the requirement.
So, for example, if I try to compile the following program:
void main() { }
under g++ version 3.3.1, I get the following message:
prog.c:1: error: `main' must return `int'
That's what the standard says should happen.
The standard does not mention any error messages when using a
different version of main(). What the standard actually implies, and
I quote research at ATT concerning this topic...
"A conforming implementation accepts
int main() { /* ... */ }

int main(int argc, char* argv[]) { /* ... */ }
A conforming implementation may provide more versions of main(),
but they must all have return type int"
(http://www.research.att.com/~bs/bs_faq2.html#void-main)

Correct.

Please read that last sentence again:

A conforming implementation may provide more versions
of main(), but they must all have return type int.

If you write "void main() { }", then main does not have return
type int. Therefore, a conforming implementation is not permitted
to accept it.
On most of the major compilers, it is permitted, so the books are correct.

That depends on whether the books purport to describe Standard C++, or
whether they are describing the dialects accepted by particular
implementationa.
Strictly speaking, it is conforming, it just isn't recommended
because it may not be portable, for example, GCC doesn't implement
any other version of main() other than the one suggested by the ISO
standard.

Strictly speaking, programs are neither conforming nor nonconforming.
The C++ standard does not impose requirements directly on programs; it
imposes requirements only on implementations. So if you want to be
strictly correct about it, you should not talk about conforming or
non-conforming programs, only about conforming or non-conforming
implementations.

It is also correct to say that conforming implementations are not
required to accept "void main()" -- in fact, they are required to
produce a diagostic message for such programs. This requirement is
often ignored in practice, but it's still there.
That proves nothing, as explained above.

What it proves is that arguments of the form "My compiler accepts it,
so it's right" are specious.
No it doesn't.

Yes it does, in subclause 3.6.1, paragraph 2.
Yes they are.

No they're not -- subclause 3.6.1 paragraph 2 makes that clear.
 
A

Andrew Koenig

Andrey> Strictly speaking, implementations are allowed to do anything they
Andrey> please as long as any compliant C++ code is interpreted correctly.

No, they're not. Implementations are also required to produce
diagnostic messages when presented with ill-formed programs, unless
the ill-formedness is described with "no diagnostic is required" in
the standard.
 
A

Andrew Koenig

Strictly speaking, implementations are allowed to do anything they
Congratulations for being the first person to talk sense in this
whole entire newsgroup.

Sorry, but you're both mistaken.

See subclause 1.4 of the standard, which says, among other things:

The set of "diagnosible rules" consists of all syntactic and
semantic rules in this International Standard except for those
rules containing an explicit notation that "no diagnostic is
required" or which are described as resulting in "undefined
behavior."

...

If a program contains a violation of any diagnosible rule,
a conforming implementation shall issue at least one
diagnostic message...

So conforming C++ implementations are not allowed to accept anything
at all unless they issue a diagnostic message for nonconforming programs.
 
A

Andrew Koenig

Then explain why the standard says it is okay to use return type IN ADDITION to
int? Why do you guys keep trying to ignore reality so you can support your
religion of "pure" C++? Here it is again for those of you who can't read yet...
"3.6.1 Main function paragraph 2:
It shall have a return type of type int

--> BUT<--
otherwise its type is implementation-defined"
Duh! The int is mandatory but void is optional.

No, that's not what the sentence says. The sentence is

It [the type of main] shall have a return type of type "int",
but otherwise its type is implementation-defined.

The return type is only part of the type of a function.

So the standard is saying that the return-type part of the type of
main is required to be "int" and the rest of the type of main is
implementation-defined.
 
A

Andrew Koenig

Try another guess. The "but" allows for different returns types, as
No, it does not. You have been told that by Herb Sutter, who *is* the
representative of Microsoft in this circles.

and who is also the convener of the ISO C++ standards committee.
 
W

WW

Andrew said:
and who is also the convener of the ISO C++ standards committee.

Yep. It is in his signature. But I doubt that a Seriously Abusive
Gibberish Emitter knows what a convener is. (To be honest I don't know
really either. I even misspell it all the time as convenor. :-( )
 
A

Andrew Koenig

I'm not saying that implicit return 0 is the greatest thing since
sliced bread, just that it is a defensible decision on the part of
the committee.

Especially if you know the history.

Here's the order in which things happened:

1) Someone noticed that the following program:

main() /* yes, I meant "main", not "int main" */
{ }

was a valid C program but not a valid C++ program.

I forget the exact reason, but it was something having to do
with subtle differences in behavior when a program fails to
return a value and its caller doesn't look at the value.

2) Accordingly, there was a proposal in the C++ committee
to put an implicit "return 0;" at the end of main, as a
compatibility hack. This proposal was accepted.

3) The C++ committee then learned that the C committee had
prohibited implicit return types entirely in C9x. This was
a surprise, as we had not expected the C committee to break
any valid C89 programs.

4) As a result, the C++ committee also proposed to prohibit
implicit return types. This proposal was also accepted.

5) Because

main() { }

was now broken (because of the lack of an explicit return type),
there was no further need for the implicit "return 0;"
I think there was even a proposal to remove it. However, the
committee decided to leave it alone because there might already
be programs out there relying on it.

Isn't compatibility wonderful?
 
W

WW

Andrew Koenig wrote:
[SNIP]
However, the committee decided to leave it alone because
there might already be programs out there relying on it.

Isn't compatibility wonderful?

That reminds me of something I have read in one of those a graffiti books.
It was something like this: "Hey, Lord! Shouldn't we erase this whole thing
and start over with some other kind of animal?" :)
 
T

The_Sage

Reply to article by: "WW said:
Date written: Fri, 26 Sep 2003 06:53:15 +0300
MsgID:<[email protected]>
Please look at Chapter 28 and let me know what do you see there about void
main.

You didn't answer the question. I take that as an admission you have no clue.

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 
T

The_Sage

Reply to article by: "David B. Held said:
Date written: Fri, 26 Sep 2003 00:58:09 -0500
MsgID:<[email protected]>
I have challenged you several times to show statements by any
of these organizations claiming that their compilers are 100%
conforming.

I have challenged you several times to show statements by any of those
organizations claiming that their compilers are less than 100% conforming. They
say they conform, therefore they are conforming. If you want to make up new
definitions for words so that "conforming" now means "almost conforming", go
right ahead, but don't be surprized if no one ever take anything seriously that
you ever say from then on.

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 
T

The_Sage

Reply to article by: Andrew Koenig said:
Date written: Fri, 26 Sep 2003 14:57:40 GMT
MsgID:<[email protected]>
and who is also the convener of the ISO C++ standards committee.

That proves nothiong expect there are alot of people who resort to the logical
fallacy of appeal to authority. The standard allows room for other types,
whether deliberately or not, and many major compiler makers use additional
types. Whether they like it or not, the standard needs to conform to what the
user needs, not what Herb or you want.

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"The men that American people admire most extravagantly are
most daring liars; the men they detest the most violently are
those who try to tell them the truth" -- H. L. Mencken
=============================================================
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top