Thread overview
[Issue 1696] New: for(;;) in CTFE segfaults compiler
Nov 28, 2007
d-bugmail
Nov 28, 2007
Ary Borenszweig
Nov 28, 2007
d-bugmail
Nov 28, 2007
Ary Borenszweig
Dec 10, 2007
d-bugmail
November 28, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1696

           Summary: for(;;) in CTFE segfaults compiler
           Product: D
           Version: 1.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: clugdbug@yahoo.com.au


Seems it's not checking for an empty iteration clause.
Putting _anything_ in there, eg for(;;null) stops the segfault.
---------
int a()
{
    bool b = false;
    for (;;) {
        if (b) return 0;
        b = true;
    }
}

const c = a();


-- 

November 28, 2007
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1696
> 
>            Summary: for(;;) in CTFE segfaults compiler
>            Product: D
>            Version: 1.023
>           Platform: PC
>         OS/Version: Windows
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: DMD
>         AssignedTo: bugzilla@digitalmars.com
>         ReportedBy: clugdbug@yahoo.com.au
> 
> 
> Seems it's not checking for an empty iteration clause.
> Putting _anything_ in there, eg for(;;null) stops the segfault.
> ---------
> int a()
> {
>     bool b = false;
>     for (;;) {
>         if (b) return 0;
>         b = true;
>     }
> }
> 
> const c = a();
> 
> 

What if there is a break somewhere in the empty for? The compiler can't know that the function will end it's execution. I think it would be weird if the compiler didn't hang up or segfault on this.
November 28, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1696


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com
           Keywords|                            |ice-on-valid-code




------- Comment #2 from smjg@iname.com  2007-11-28 08:25 -------
Ary, what do you mean by this?

And please don't quote the entire message posted to the newsgroup when replying.  It's bad enough on any newsgroup, and when it clutters up Bugzilla, it's even worse.


-- 

November 28, 2007
Sorry, I meant nothing. I was very drowsy I guess.
December 10, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1696


davidl@126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE




------- Comment #4 from davidl@126.com  2007-12-09 19:17 -------


*** This bug has been marked as a duplicate of 1072 ***


--