Thread overview
[Issue 1573] New: ICE when using -O flag and static if's
Oct 11, 2007
d-bugmail
Oct 12, 2007
d-bugmail
Oct 13, 2007
d-bugmail
Oct 15, 2007
d-bugmail
Oct 15, 2007
d-bugmail
Oct 15, 2007
d-bugmail
Oct 15, 2007
d-bugmail
Oct 16, 2007
d-bugmail
October 11, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1573

           Summary: ICE when using -O flag and static if's
           Product: DGCC aka GDC
           Version: 0.24
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn@users.sf.net
        ReportedBy: jeffd@gwava.com


I made some performance changes by adding a static if to a hash keyCompare function to deal with null.opEquals issues:

private bool _keyCompare(T first, T second)
{
        static if (is(T : Object))
                return cast(bool)(first ? first == second : second is null);
        return cast(bool)(second == first);
}

While testing, I was able to compile fine (with -O, etc), however, linking in a Config module that uses the Hash template in several places, I get:

tetra/util/container/Hash.d: In member function ‘_keyCompare’:
tetra/util/container/Hash.d:215: internal compiler error: in emit_move_insn, at
expr.c:3162
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>.

Line 215.d of Hash.d is the declaration of the _keyCompare function.

That's with compiling with -O -release. Removing the -O it compiles and runs as expected.

Changing the line:      return cast(bool)(second == first); to just return
false; also allows compilation without error (but doesn't run as expected,
obviously).


-- 

October 12, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1573





------- Comment #1 from jeffd@gwava.com  2007-10-12 11:04 -------
Little update,

changing the _keyCompare function to the following removes the ICE:

private bool _keyCompare(T first, T second)
{
        static if (is(T : Object))
                return cast(bool)(first ? first == second : second is null);
        if (first == second)
                return true;
       return false;
}


-- 

October 13, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1573


dvdfrdmn@users.sf.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




------- Comment #2 from dvdfrdmn@users.sf.net  2007-10-13 15:38 -------
Cannot reproduce.  Can you post a self-contained example or a URL to get the full source?  You may also want to try a newer Debian package if one is available.


-- 

October 15, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1573





------- Comment #3 from jeffd@gwava.com  2007-10-15 14:43 -------
I've tried the latest .deb, exact same error.

I would have to package up stuff from our commercial source to give to you to replicate the issue, as with smaller test cases, there is no compiler issue.

Unfortunately, I'm not sure if I can get permission to give you one of the required components.

The Hash component wouldn't be an issue however.

I'll try and make something that replicates the issue without using the component that I can't give and post it here.


-- 

October 15, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1573





------- Comment #4 from jeffd@gwava.com  2007-10-15 14:51 -------
Created an attachment (id=192)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=192&action=view)
Hash that causes the compilation error.


-- 

October 15, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1573





------- Comment #5 from jeffd@gwava.com  2007-10-15 14:52 -------
Created an attachment (id=193)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=193&action=view)
main() used to create compilation error


-- 

October 15, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1573





------- Comment #6 from jeffd@gwava.com  2007-10-15 14:54 -------
$ gdc --version
gdc (GCC) 4.1.3 20070831 (prerelease gdc 0.25, using dmd 1.021) (Ubuntu
0.25-4.1.2-16ubuntu1)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

I'm using tango and "rebuild":

$ rebuild test2.d -release -O -full
WARNING: Module test2.d does not have a module declaration. This can cause
problems
         with rebuild's -oq option. If an error occurs, fix this first.
tetra/util/container/Hash.d: In member function ‘_keyCompare’:
tetra/util/container/Hash.d:214: internal compiler error: in emit_move_insn, at
expr.c:3162
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>.


If you go to line 222, I've commented out the chunk of code we used to work around the issue.


-- 

October 16, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1573


dvdfrdmn@users.sf.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




------- Comment #7 from dvdfrdmn@users.sf.net  2007-10-15 23:09 -------
Fixed in svn rev 190 / release 0.25


--