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).
Comment #1 by jeffd — 2007-10-12T11:04:28Z
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;
}
Comment #2 by dvdfrdmn — 2007-10-13T15:38:15Z
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.
Comment #3 by jeffd — 2007-10-15T14:43:35Z
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.
Comment #4 by jeffd — 2007-10-15T14:51:28Z
Created attachment 192
Hash that causes the compilation error.
Comment #5 by jeffd — 2007-10-15T14:52:02Z
Created attachment 193
main() used to create compilation error
Comment #6 by jeffd — 2007-10-15T14:54:11Z
$ 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.