www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Another case of debug/version IPF: for loops

reply Stewart Gordon <smjg_1998 yahoo.com> writes:
(Accidentally posted before to the wrong 'group.  Hopefully my cancel 
request worked....)

Using DMD 0.120, Windows 98SE.

This code crashes DMD with an IPF, just like it did within catch blocks 
before.

---------
void main() {
	for (int i = 0; i < 10; i++) {
		debug writefln(i);
	}
}
---------
DMD caused an invalid page fault in
module DMD.EXE at 0167:00429038.
Registers:
EAX=00724dc8 CS=0167 EIP=00429038 EFLGS=00010202
EBX=007299dc SS=016f ESP=0070fb60 EBP=0072a2c8
ECX=00000000 DS=016f ESI=0072a32c FS=4d87
EDX=004b1598 ES=016f EDI=0072a32c GS=0000
Bytes at CS:EIP:
8b 01 ff 50 3c b8 01 00 00 00 59 c3 51 53 89 cb
Stack dump:
00724dc8 0041e95f 007299dc 007297c0 00000001 004947ae 00000000 00000000
0070fc3c 0072fad8 0072edf4 00000035 00720540 0049fd5e 0072edf4 00000020
---------

Again, it applies equally to debug or version.  Again, the presence or 
absence of braces around either the for content or the debug content 
doesn't seem to make a difference.

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on 
the 'group where everyone may benefit.
Apr 18 2005
next sibling parent reply zwang <nehzgnaw gmail.com> writes:
Stewart Gordon wrote:
 (Accidentally posted before to the wrong 'group.  Hopefully my cancel 
 request worked....)
 
 Using DMD 0.120, Windows 98SE.
 
 This code crashes DMD with an IPF, just like it did within catch blocks 
 before.
 
 ---------
 void main() {
     for (int i = 0; i < 10; i++) {
         debug writefln(i);
     }
 }
 ---------
 DMD caused an invalid page fault in
 module DMD.EXE at 0167:00429038.
 Registers:
 EAX=00724dc8 CS=0167 EIP=00429038 EFLGS=00010202
 EBX=007299dc SS=016f ESP=0070fb60 EBP=0072a2c8
 ECX=00000000 DS=016f ESI=0072a32c FS=4d87
 EDX=004b1598 ES=016f EDI=0072a32c GS=0000
 Bytes at CS:EIP:
 8b 01 ff 50 3c b8 01 00 00 00 59 c3 51 53 89 cb
 Stack dump:
 00724dc8 0041e95f 007299dc 007297c0 00000001 004947ae 00000000 00000000
 0070fc3c 0072fad8 0072edf4 00000035 00720540 0049fd5e 0072edf4 00000020
 ---------
 
 Again, it applies equally to debug or version.  Again, the presence or 
 absence of braces around either the for content or the debug content 
 doesn't seem to make a difference.
 
 Stewart.
 

Confirmed on WinXP, dmd .121. Besides, a while loop may also produce the problem: <code> void main(){ while(1) debug; } </code>
Apr 18 2005
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
zwang wrote:
<snip>
 Besides, a while loop may also produce the problem:
 <code>
 void main(){
     while(1)
         debug;
 }
 </code>

I also tried my snippet with while, if and switch, and the problem didn't show. But what does debug; by itself mean? My guess is that it's this that's crashing the compiler when you try.... Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 18 2005
parent reply zwang <nehzgnaw gmail.com> writes:
Stewart Gordon wrote:
 zwang wrote:
 <snip>
 
 Besides, a while loop may also produce the problem:
 <code>
 void main(){
     while(1)
         debug;
 }
 </code>

I also tried my snippet with while, if and switch, and the problem didn't show. But what does debug; by itself mean? My guess is that it's this that's crashing the compiler when you try.... Stewart.

";" is an empty statement that does nothing.
Apr 18 2005
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
zwang wrote:
<snip>
 ";" is an empty statement that does nothing.

According to which bit of the D spec? From what I recall, Walter deliberately left this out to avoid the common C typo of if (qwert == 42); yuiop(); Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 18 2005
parent reply zwang <nehzgnaw gmail.com> writes:
Stewart Gordon wrote:
 zwang wrote:
 <snip>
 
 ";" is an empty statement that does nothing.

According to which bit of the D spec? From what I recall, Walter deliberately left this out to avoid the common C typo of if (qwert == 42); yuiop(); Stewart.

You are correct. According to the spec, "Expressions that have no effect, like (x + x), are illegal in expression statements." But an illegal statement should not crash a compiler, right?
Apr 18 2005
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
zwang wrote:
 Stewart Gordon wrote:
 
 zwang wrote:
 <snip>

 ";" is an empty statement that does nothing.

According to which bit of the D spec? From what I recall, Walter deliberately left this out to avoid the common C typo of if (qwert == 42); yuiop(); Stewart.

You are correct. According to the spec, "Expressions that have no effect, like (x + x), are illegal in expression statements."

Not only that, but in your example there is no expression at all, so such a thing isn't even syntactically valid.
 But an illegal statement should not crash a compiler, right?

Correct. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 18 2005
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
Stewart Gordon <smjg_1998 yahoo.com> wrote:

[...]
 but in your example there is no expression at
 all, so such a thing isn't even syntactically valid.

Nope. It is an empty declaration, specific a "DeclDef": http://www.digitalmars.com/d/module.html -manfred
Apr 18 2005
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Manfred Nowak wrote:
 Stewart Gordon <smjg_1998 yahoo.com> wrote:
 
 [...]
 
 but in your example there is no expression at 
 all, so such a thing isn't even syntactically valid.

Nope. It is an empty declaration, specific a "DeclDef": http://www.digitalmars.com/d/module.html

Nope. A DeclDef isn't a valid form of statement. The DeclDef applies only at module level. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 19 2005
parent Manfred Nowak <svv1999 hotmail.com> writes:
Stewart Gordon <smjg_1998 yahoo.com> wrote:

[...]
 Nope.  A DeclDef isn't a valid form of statement.  The DeclDef
 applies only at module level.

According to the current specs correct. But according to the implementation empty declarations are allowed also in class and function bodys. Astonishingly the specs currently do not hold a definition for "functionBody". So: what to fix? -manfred
Apr 19 2005
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stewart Gordon schrieb am Mon, 18 Apr 2005 11:29:51 +0100:
 (Accidentally posted before to the wrong 'group.  Hopefully my cancel 
 request worked....)

 Using DMD 0.120, Windows 98SE.

 This code crashes DMD with an IPF, just like it did within catch blocks 
 before.

 ---------
 void main() {
 	for (int i = 0; i < 10; i++) {
 		debug writefln(i);
 	}
 }
 ---------

Added to DStress as http://dstress.kuehne.cn/run/do_while_04.d http://dstress.kuehne.cn/run/do_while_05.d http://dstress.kuehne.cn/run/else_01.d http://dstress.kuehne.cn/run/else_02.d http://dstress.kuehne.cn/run/for_04.d http://dstress.kuehne.cn/run/for_05.d http://dstress.kuehne.cn/run/foreach_28.d http://dstress.kuehne.cn/run/foreach_29.d http://dstress.kuehne.cn/run/if_07.d http://dstress.kuehne.cn/run/if_08.d http://dstress.kuehne.cn/run/while_04.d http://dstress.kuehne.cn/run/while_05.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCY7ah3w+/yD4P9tIRAmaEAKDPOmJTYmp/cB4QagI+uUH4ap3XQwCgxMlp 0GQA5WiZeAwulcOv3jmvkHw= =ptSR -----END PGP SIGNATURE-----
Apr 18 2005