Board index » cppbuilder » Re: exit bug in free bcc32 compiler v5.5

Re: exit bug in free bcc32 compiler v5.5


2003-10-29 02:10:44 AM
cppbuilder34
As far as I know what the standard says is that the function main is allowed
to not have a statement returning a specific value from main.
I remember nothing that says it can be given as returning void.
I have no idea why someone who would understand C++ would need to be helped
by the removal of the need to return a value from main and less idea of why
returning void has value unless it is the author for some reason wishes to
give the impression that he does not know the language.
. Ed
Quote
Faz wrote in message
news:3f9eaed7$ XXXX@XXXXX.COM ...

According to the latest iso standard, you are now allowed
to declare main to have a void return, but this throws bcc32,
for some weird reason when <iostream>is included..
 
 

Re:Re: exit bug in free bcc32 compiler v5.5

"Faz" <Fazl-dot-Rahman-At-Web-Dot-DE>wrote:
Quote
According to the latest iso standard, you are now allowed to declare main to
have a void return
_Really_?
I must have missed that vote entirely - ISO/IEC 14482:1998 had main()
returning int, and I wasn't aware that the TC had changed it.
Do you have any evidence for your statement?
(I assume you're not referring to the special clause 3.6.1/5 where lack
of a return is equivalent to return 0.)
Alan Bellingham
--
Team Mongolian Wok
<url:www.borland.com/newsgroups/>Borland newsgroup descriptions
<url:www.borland.com/newsgroups/netiquette.html>netiquette
 

Re:Re: exit bug in free bcc32 compiler v5.5

According to the latest iso standard, you are now allowed to declare main to
have a void return, but this throws bcc32, for some weird reason when
<iostream>is included..
Anyway, just in case someone's been pulling their hair out, the attached
demonstrator code may help. The obvious workaround is declare main to
return an int. I found I can prevent the crash by adding a return statement
even when main has a void return declared (Duh..).
If anyone has constructive feedback, it would be welcomed cc-d to me, you
have to unscramble my email address first of course.
Happy coding etc.
Faz
/*
Demonstrate a core-dump produced by mix of Borlands bcc32 v5.5 with
STLPort 4.5.3 on Cygwin (win2k).
2003/Oct/26 Bonn
*/
//------------- Compiles/links ok, as expected, but core-dumps at end of
execution.
#include <iostream>// THIS INCLUDE IS NEEDED TO ELICIT THE
COREDUMP!
#include <map>
void main(){
std::map<int, int>mii;
}
// A couple of variations with different behaviour..
/*
// VARIATION 1 Works fine, as expected..
#include <iostream>
#include <map>
int main(){
std::map<int, int>mii;
return 0;
}
*/
/*
// VARIATION 2
#include <iostream>
#include <map>
void main(){
std::map<int, int>mii;
exit( 0 ); //This pre-empts the core dump, presumably
patches in correct tidyup.
}
*/
 

{smallsort}

Re:Re: exit bug in free bcc32 compiler v5.5

"Ed Mulroy [TeamB]" < XXXX@XXXXX.COM >wrote:
Quote
I have no idea why someone who would understand C++ would need to be helped
by the removal of the need to return a value from main
It makes the standard shorter. Not much, but a bit.
Alan Bellingham
--
Team Mongolian Wok
<url:www.borland.com/newsgroups/>Borland newsgroup descriptions
<url:www.borland.com/newsgroups/netiquette.html>netiquette
 

Re:Re: exit bug in free bcc32 compiler v5.5

"Ed Mulroy [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
As far as I know what the standard says is that the function main is
allowed
to not have a statement returning a specific value from main.

I remember nothing that says it can be given as returning void.
That surprised me so I took a look in a book.. and you're right. Thankyou
for this constructive piece of feedback.
Maybe one day I'll get out of the bad habit of trying things out with a
quick 'void main(){ /**/ }'.
Shame the compiler doesn't know this fact.. I've begun relying on it in my
laziness.
Quote
I have no idea why someone who would understand C++ would need to be
helped
by the removal of the need to return a value from main and less idea of
why
returning void has value unless it is the author for some reason wishes to
give the impression that he does not know the language.
(I do believe the man's trying to be subtle here :-)
Indeed, I've only been doing C++ programming for a short time (11 years ;-),
and there's lots and lots more to learn all the time. Unfortunately
sometimes the learning doesn't keep up with the forgetting.
I'm glad there are people on this newsgroup generous enough to share of
their valuable time and hard-earned experience.
Cheers,
Faz
 

Re:Re: exit bug in free bcc32 compiler v5.5

"Alan Bellingham" < XXXX@XXXXX.COM >wrote in message
Quote
"Faz" <Fazl-dot-Rahman-At-Web-Dot-DE>wrote:

>According to the latest iso standard, you are now allowed to declare main
to
>have a void return

_Really_?
[..demand for evidence snipped..]
It's Okay Alan, relax. Your counterpart from Team B has already gently
pointed out that one. I should have said 'you are now allowed to not bother
returning a value explicitly from main'. No doubt I'll make the same
mistake again in a couple of years, if I'm still using C++.
What really unsettled me enough to post the original, is how adding or
removing "#include <iostream>" can toggle a runtime coredump.
Kind regards,
Faz
 

Re:Re: exit bug in free bcc32 compiler v5.5

Ok, I've been slapped with sarcasm and I deserved it. Point made.
The compiler accepts void main because of all the software examples that
eminate from a place in the upper left corner of the US which use void as
the return type. It is part of what they did to accept legacy code.
. Ed
"Faz" <Fazl-dot-Rahman-At-Web-Dot-DE>wrote in message
Quote
...

Indeed, I've only been doing C++ programming for a
short time (11 years ;-), and there's lots and lots
more to learn all the time. Unfortunately sometimes
the learning doesn't keep up with the forgetting.

I'm glad there are people on this newsgroup
generous enough to share of their valuable time and
hard-earned experience.