D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11201 - ICE: (symbol.c) -inline stops compilation
Summary: ICE: (symbol.c) -inline stops compilation
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: ice, pull
Depends on:
Blocks:
 
Reported: 2013-10-08 22:37 UTC by daniel
Modified: 2020-02-08 08:54 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description daniel 2013-10-08 22:37:35 UTC
struct Foo {
	float a, b;

	Foo opUnary(string op)() const { return this; }
	Foo opBinary(string op)(float) { return this; }
}

auto f1(T)(T a) { return 1; }
auto f2(T)(T a) { return a * f1(a); }

void main() {}

unittest {
	auto a = Foo(0, 1);

	assert(f2(-a) == a);
}


I've reduce the code as much I thought possible, removal of anything else stops the ICE occuring.
When compiling the above code, with the following command line arguments:

`dmd -unittest -inline test.d`

Displays

`Internal error: backend/symbol.c 1036`

Confirmed with Arch Linux and OSX.
Comment 1 daniel 2013-10-08 22:39:04 UTC
Confirmed on Git HEAD (511b24a457)
Comment 2 daniel 2013-10-08 22:43:06 UTC
Further reduced:

struct Foo {
	float a, b;

	Foo opUnary(string op)() const { return this; }
}

auto f1(T)(T a) { return a; }
auto f2(T)(T a) { return f1(a); }

void main() {}

unittest {
	auto a = Foo(0, 1);

	assert(f2(-a) == a);
}
Comment 3 yebblies 2013-11-13 23:56:21 UTC
Does not require -unittest

struct Foo {
    int a;
    float b;

    Foo func()() const { return this; }
}

auto f1()(Foo a) { return a; }

void main() {
    auto a = Foo(0, 1);

    cast(void)(f1(a.func!()()) == a);
}

Produces this ast for main:

Foo a = Foo(0, 1.00000F);
cast(void)((Foo __inlineretval2 = Foo a = Foo __inlineretval1 = ref Foo this = a
;
 , (assert(&this, "null this") , this);
 , __inlineretval1;
 , a;
 , __inlineretval2).a == a.a && (Foo __inlineretval3 = Foo a = Foo __inlineretva
l1 = ref Foo this = a;
 , (assert(&this, "null this") , this);
 , __inlineretval1;
 , a;
 , __inlineretval3).b == a.b);
return 0;

The most suspect thing is that __inlineretval1 is declared twice - the crash in symbol.c happens on this symbol with assert(s->Ssymnum == -1); - ie the symbol is already numbered.
Comment 5 github-bugzilla 2014-06-17 20:39:02 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/fe9bdcce89530fdefcff743bf50b6b6f9d913a7a
fix Issue 11201 - ICE: (symbol.c) -inline stops compilation

https://github.com/D-Programming-Language/dmd/commit/7ec843a6f5232e8eb53991c6b11b790d2cd61278
Merge pull request #3672 from 9rnsr/fix11201

Issue 11201 - ICE: (symbol.c) -inline stops compilation