[Issue 3174] ICE(mtype.c): Compiler crash or compiler error with auto returns and const / immutable / invarient / pure
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 2 00:08:14 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3174
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #1 from Don <clugdbug at yahoo.com.au> 2009-10-02 00:08:13 PDT ---
There are actually 2 independent bugs here. My patch only deals with the ICE.
I've created bug 3359 for the parsing failure.
CAUSE: It's trying to do type->deco->merge() on a function, when it doesn't yet
know the return type. merge() is never done on plain auto functions, which is
why the thrid case doesn't segfault.
COMMENT: mtype.c, TypeFunction::toDecoBuffer() desperately needs an
assert(next); to generate an ICE instead of a segfault. I have seen at least
five different
bugs that crash there.
PATCH: I've done this by copy-and-paste, you probably want to reorganize this
function a bit to avoid duplication. This makes 'const' functions behave the
same as 'auto'
-- but actually plain 'auto' functions suffer from the other bugs, I think
because the merge() never happens.
Index: func.c
===================================================================
--- func.c (revision 75)
+++ func.c (working copy)
@@ -144,6 +144,13 @@
* to the function type
*/
type = type->semantic(loc, sc);
+ if (type->ty != Tfunction)
+ {
+ error("%s must be a function", toChars());
+ return;
+ }
+ f = (TypeFunction *)(type);
+
unsigned stc = storage_class;
if (type->isInvariant())
stc |= STCimmutable;
@@ -159,22 +166,22 @@
case STCimmutable | STCshared:
// Don't use toInvariant(), as that will do a merge()
type = type->makeInvariant();
- type->deco = type->merge()->deco;
+ if (f->next) type->deco = type->merge()->deco;
break;
case STCconst:
type = type->makeConst();
- type->deco = type->merge()->deco;
+ if (f->next) type->deco = type->merge()->deco;
break;
case STCshared | STCconst:
type = type->makeSharedConst();
- type->deco = type->merge()->deco;
+ if (f->next) type->deco = type->merge()->deco;
break;
case STCshared:
type = type->makeShared();
- type->deco = type->merge()->deco;
+ if (f->next) type->deco = type->merge()->deco;
break;
case 0:
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list