www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - if(0) / goto / return

reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

goto_09.d










 function main function expected to return a value of type int
test cases: http://svn.kuehne.cn/dstress/run/goto_08.d http://svn.kuehne.cn/dstress/run/goto_09.d Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.13 (GNU/Linux) iD8DBQFBt/an3w+/yD4P9tIRAu0SAJ91qG6O+c6FVWyEXEEQpRf2oce4LgCghAuA 1TxdeyrCvMRSPuigMfCnbeo= =ANlH -----END PGP SIGNATURE-----
Dec 08 2004
parent reply "Simon Buchan" <currently no.where> writes:
On Thu, 9 Dec 2004 07:54:32 +0100, Thomas Kuehne  
<thomas-dloop kuehne.thisisspam.cn> wrote:

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 goto_09.d










 function main function expected to return a value of type int
test cases: http://svn.kuehne.cn/dstress/run/goto_08.d http://svn.kuehne.cn/dstress/run/goto_09.d Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.13 (GNU/Linux) iD8DBQFBt/an3w+/yD4P9tIRAu0SAJ91qG6O+c6FVWyEXEEQpRf2oce4LgCghAuA 1TxdeyrCvMRSPuigMfCnbeo= =ANlH -----END PGP SIGNATURE-----
Im not sure this counts as a bug... putting a return somewhere around that assert should workaround it if you manage to find a case where this matters. (Cases like this where the compiler is expected to reduce the code for you would only introduce bugs, IMHO, something dmd has WELL underhand (;) Walter)) -- "Unhappy Microsoft customers have a funny way of becoming Linux, Salesforce.com and Oracle customers." - www.microsoft-watch.com: "The Year in Review: Microsoft Opens Up" -- "I plan on at least one critical patch every month, and I haven't been disappointed." - Adam Hansen, manager of security at Sonnenschein Nath & Rosenthal LLP (Quote from http://www.eweek.com/article2/0,1759,1736104,00.asp) -- "It's been a challenge to "reteach or retrain" Web users to pay for content, said Pizey" -Wired website: "The Incredible Shrinking Comic"
Dec 09 2004
parent reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Simon Buchan schrieb am Fri, 10 Dec 2004 03:14:55 +1300:
 On Thu, 9 Dec 2004 07:54:32 +0100, Thomas Kuehne  
<thomas-dloop kuehne.thisisspam.cn> wrote:

 goto_09.d










 function main function expected to return a value of type int
test cases: http://svn.kuehne.cn/dstress/run/goto_08.d http://svn.kuehne.cn/dstress/run/goto_09.d
Im not sure this counts as a bug... putting a return somewhere around that assert should workaround it if you manage to find a case where this matters. (Cases like this where the compiler is expected to reduce the code for you would only introduce bugs, IMHO, something dmd has WELL underhand (;) Walter))
Actually it seems to be exactly a bug where the compiler _did_ reduce the code. Compare with the goto_08 test - it's the same, only that the if condition isn't static. goto_08 compiles and executes without a glitch. Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.13 (GNU/Linux) iD8DBQFBuF+V3w+/yD4P9tIRAoj+AJ9Ja2eS+fjBkxa0ev9q3k/SjK4JRQCgqA+1 5/CZDQiQ2DHYZzucR+jOHtg= =GUQX -----END PGP SIGNATURE-----
Dec 09 2004
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


 Simon Buchan schrieb am Fri, 10 Dec 2004 03:14:55 +1300:
 On Thu, 9 Dec 2004 07:54:32 +0100, Thomas Kuehne  
<thomas-dloop kuehne.thisisspam.cn> wrote:

 goto_09.d










 function main function expected to return a value of type int
test cases: http://svn.kuehne.cn/dstress/run/goto_08.d http://svn.kuehne.cn/dstress/run/goto_09.d
Im not sure this counts as a bug... putting a return somewhere around that assert should workaround it if you manage to find a case where this matters. (Cases like this where the compiler is expected to reduce the code for you would only introduce bugs, IMHO, something dmd has WELL underhand (;) Walter))
Actually it seems to be exactly a bug where the compiler _did_ reduce the code.
The culprit is statement.c -> *IfStatement::semantic. Either the short-circuit evaluation has to be disable (that's what I am currently doing) or the short-circuit evaluation has to look for labels referenced from outside. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFBvrkD3w+/yD4P9tIRApYNAKC0cYktRoxZ8SyG2T9cg1HS9nHpvACgoXod 9kVZKNqsZ7YWuL1PU1O1Low= =ufPR -----END PGP SIGNATURE-----
Dec 14 2004