digitalmars.D.bugs - empty unittest fails
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (7/7) Mar 01 2005 This code fails, with -unittest:
- Derek (13/27) Mar 01 2005 It doesn't fail on Windows XP.
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/9) Mar 01 2005 I meant the return code. Not sure how you use those on windows... ?
- Derek (28/41) Mar 01 2005 With people like me, you have just gotta be a whole lot more specific, a...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (6/18) Mar 01 2005 It means you always have to use "int main" and "return EXIT_SUCCESS",
- Ben Hinkle (4/11) Mar 01 2005 Techinically this isn't a bug, right? The compiler is behaving exactly a...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/10) Mar 01 2005 Not really a bug, no. Just a "missed opportunity" to be better than C...
- Rob Grainger (14/24) Mar 01 2005 I'd say you're both right here - void main() is nice - I use it a lot, b...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (15/26) Mar 02 2005 If you do need to return a code, you use "int main" instead.
- Manfred Nowak (4/11) Mar 02 2005 According to Matthew this program shouldn't be compilable.
- Derek (8/21) Mar 02 2005 I thought he was saying that its okay to compile this, but tell me about
- Manfred Nowak (4/7) Mar 02 2005 Is this the way how rumors come into living? :-)
This code fails, with -unittest: unittest {} void main() {} This bug is just a variant of: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2677 And the suggested (partial) patch: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2853 --anders
Mar 01 2005
On Tue, 01 Mar 2005 12:02:15 +0100, Anders F Björklund wrote:This code fails, with -unittest: unittest {} void main() {} This bug is just a variant of: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2677 And the suggested (partial) patch: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2853 --andersIt doesn't fail on Windows XP. f:\temp>type test.d unittest {} void main() {} f:\temp>dmd test.d -unittest f:\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi; f:\temp>test f:\temp>dmd Digital Mars D Compiler v0.114 Copyright (c) 1999-2005 by Digital Mars written by Walter Bright -- Derek Melbourne, Australia
Mar 01 2005
Derek wrote:I meant the return code. Not sure how you use those on windows... ? On unix, you can do stuff like: ./unittest && echo PASS || echo FAIL --andersThis code fails, with -unittest: unittest {} void main() {}It doesn't fail on Windows XP.
Mar 01 2005
On Tue, 01 Mar 2005 12:29:32 +0100, Anders F Björklund wrote:Derek wrote:With people like me, you have just gotta be a whole lot more specific, and show examples ;-) Ok, so you are saying that using 'void main()' causes a non-zero return code to be sent back to the operating system. Well, I can confirm that in Windows too then. --- First with a definite ZERO returned ---- f:\temp>type test.d unittest {} int main() {return 0;} f:\temp>dmd -unittest test.d f:\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi; f:\temp>test & if errorlevel 1 echo fail f:\temp> Okay that worked as expected. Now the VOID version ... f:\temp>type test.d unittest {} void main() {} f:\temp>dmd -unittest test.d f:\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi; f:\temp>test & if errorlevel 1 echo fail fail f:\temp> So a 'void main()' returns a non-zero. I guess it would be nice if it returned zero. Sure make some people's work easier. BTW, what has -unittest got to do with this bug? -- Derek Melbourne, AustraliaI meant the return code. Not sure how you use those on windows... ? On unix, you can do stuff like: ./unittest && echo PASS || echo FAIL --andersThis code fails, with -unittest: unittest {} void main() {}It doesn't fail on Windows XP.
Mar 01 2005
Derek wrote:With people like me, you have just gotta be a whole lot more specific, and show examples ;-) Ok, so you are saying that using 'void main()' causes a non-zero return code to be sent back to the operating system.Yes, I didn't bother repeating myself but just linked... :-)So a 'void main()' returns a non-zero. I guess it would be nice if it returned zero. Sure make some people's work easier. BTW, what has -unittest got to do with this bug?It means you always have to use "int main" and "return EXIT_SUCCESS", or your unit tests will always fail. Like you say, that's a pain... Otherwise, the other bug is unrelated.cdouble main() { return 1.0 + 2.0i; }--anders
Mar 01 2005
"Anders F Björklund" <afb algonet.se> wrote in message news:d01i3p$2d7p$1 digitaldaemon.com...This code fails, with -unittest: unittest {} void main() {} This bug is just a variant of: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2677 And the suggested (partial) patch: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2853 --andersTechinically this isn't a bug, right? The compiler is behaving exactly as designed.
Mar 01 2005
Ben Hinkle wrote:Not really a bug, no. Just a "missed opportunity" to be better than C... I like "void main() {}" a lot, and wish that it will be fixed and stay. --andersThis bug is just a variant of: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2677Techinically this isn't a bug, right? The compiler is behaving exactly as designed.
Mar 01 2005
I'd say you're both right here - void main() is nice - I use it a lot, but generally not where the return code is of some use. I don't really see how you can decide how to set it otherwise - the program may actually have failed, in which case returning success is just as disastrous. One possible approach - to contradict myself :) - would be to have void main() return 0 normally, but nonzero if main() was exited by an unhandled exception ? Rob "Anders F Björklund" <afb algonet.se> wrote in message news:d01o9v$2jsg$1 digitaldaemon.com...Ben Hinkle wrote:Not really a bug, no. Just a "missed opportunity" to be better than C... I like "void main() {}" a lot, and wish that it will be fixed and stay. --andersThis bug is just a variant of: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2677Techinically this isn't a bug, right? The compiler is behaving exactly as designed.
Mar 01 2005
Rob Grainger wrote:I'd say you're both right here - void main() is nice - I use it a lot, but generally not where the return code is of some use. I don't really see how you can decide how to set it otherwise - the program may actually have failed, in which case returning success is just as disastrous.If you do need to return a code, you use "int main" instead. Similar to parameters: no need for parameters => "main()" want to access them => "main(char[][] args)" And if you change your mind, there's always: std.c.stdlib.exit(1);One possible approach - to contradict myself :) - would be to have void main() return 0 normally, but nonzero if main() was exited by an unhandled exception ?It already does that, which was part of the point of the unittest issue. int main() { throw new Exception(""); return 0; } This program has an exit code of "1". --anders
Mar 02 2005
Anders F Björklund <afb algonet.se> wrote: [...]int main() { throw new Exception(""); return 0; } This program has an exit code of "1".According to Matthew this program shouldn't be compilable. -manfred
Mar 02 2005
On Wed, 2 Mar 2005 13:48:16 +0000 (UTC), Manfred Nowak wrote:Anders F Björklund <afb algonet.se> wrote: [...]I thought he was saying that its okay to compile this, but tell me about the unreachable statements. -- Derek Parnell Melbourne, Australia http://www.dsource.org/projects/build 3/03/2005 2:13:37 AMint main() { throw new Exception(""); return 0; } This program has an exit code of "1".According to Matthew this program shouldn't be compilable.
Mar 02 2005
Derek <derek psych.ward> wrote: [...]Is this the way how rumors come into living? :-) -manfredAccording to Matthew this program shouldn't be compilable.I thought he was saying that its okay to compile this, but tell me about the unreachable statements.
Mar 02 2005