D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2969 - ICE(cod4.c) using const function parameter inside delegate
Summary: ICE(cod4.c) using const function parameter inside delegate
Status: RESOLVED DUPLICATE of issue 2560
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-05-12 18:32 UTC by Mikola Lysenko
Modified: 2015-06-09 01:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Mikola Lysenko 2009-05-12 18:32:13 UTC
Try compiling following snippet:

module sound;

import std.math;

struct Sound
{
	float time;
	float delegate(float) func;
	
	this(float delegate(float) f, float t)
	{
		time = t;
		func = f;
	}
	
	Sound opAdd(const(Sound) other)
	{
		return Sound(
		(float t){
			return func(t) + other.func(t);
		}, fmax(time, other.time));
	}
	
	Sound opCat(const(Sound) other)
	{
		return Sound(
		(float t){
			if(t <= time)
				return func(t);
			return other.func(t - time);
		}, time + other.time);
	}
	
}


Gives the error message:
Internal error: ../ztc/cod4.c 353
Comment 1 Gide Nwawudu 2009-05-13 02:24:57 UTC
Shorter version.

struct Sound {
    int delegate(int) func;

    this(int delegate(int) f) {
    }

    Sound opAdd(const(Sound) other)
    {
        return Sound(
        (int t){
            return other.func(0);
        });
    }

}
Comment 2 Don 2009-05-13 11:19:45 UTC
This _might_ be a duplicate of 2560 or 2875.
Comment 3 Don 2009-08-05 00:15:43 UTC
Even shorter test case:

struct S {
    int q;
}

void foo(const(S) x) {
   int delegate(int t) bar = (int t){ return 1 + x.q; };
}
Comment 4 Don 2009-08-31 02:25:02 UTC
This is another duplicate of 2560. Worked in 2.022.

*** This issue has been marked as a duplicate of issue 2560 ***