www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - what is going on with cgcs.c:351?

reply "Vlad Levenfeld" <vlevenfeld gmail.com> writes:
I've bumped up against this cryptic error from time to time. I 
can't really pin it down to a simple self contained example as it 
tends to come up when I try to have template-heavy modules 
interact and there is a lot to untangle.

I can't see the pattern in my code that triggers the assertion 
failure. Right now, its happening when attempting to use a struct 
that returns itself after each option is set, so that I can chain 
options... when I use this struct in one part of my code, it's 
fine. When I use it in another, I get a failure at 
backend/cgcs:351... but only if I try to set any of the options.

I've been slowly making my way through my code trying to bracket 
the problem but there's a lot of complicating factors, like 
Algebraic!T and templated constructors and structs that alias 
functions that retrieve from __gshared associative arrays, so it 
is going slowly.

Looking through the source cgcs.c, it seems to have something to 
do with operators and/or parsing expression trees. Maybe the 
error is caused by my use of opDispatch, or forwarding operator 
functions to aliases. The only other hint is this comment in the 
source code: /* optelem() should have removed these */

What should I do in this situation?
Jun 14 2014
next sibling parent reply "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Sun, Jun 15, 2014 at 04:44:06AM +0000, Vlad Levenfeld via
Digitalmars-d-learn wrote:
 I've bumped up against this cryptic error from time to time. I can't really
 pin it down to a simple self contained example as it tends to come up when I
 try to have template-heavy modules interact and there is a lot to untangle.
Have you tried Vladimir Panteleev's excellent DustMite utility? It takes a (potentially very complicated) D source tree, a test command the checks for the particular failure you're experiencing, and incrementally reduces your code until it finds a minimal case that reproduces that error. Very handy for reducing large complicated projects that triggers an internal compiler error when it's infeasible to do the reduction by hand. It *may* sometimes take a long time to reduce the code, so it does help if you can remove the obviously irrelevant parts by hand first, but in any case it's better than trying to do the full reduction yourself -- you could let it run in the background while you work on something else in the meantime. T -- I am a consultant. My job is to make your job redundant. -- Mr Tom
Jun 14 2014
next sibling parent "Vlad Levenfeld" <vlevenfeld gmail.com> writes:
I had not heard of this tool before. This looks like it's going 
to be very handy, thank you!
Jun 14 2014
prev sibling parent "Trass3r" <un known.com> writes:
I think it should be possible to run DustMite on some big project 
like phobos to actually search for such internal errors.
Jun 17 2014
prev sibling next sibling parent reply "Vlad Levenfeld" <vlevenfeld gmail.com> writes:
Update and clarification:

this triggers the error:
flight_info.add (Plot (ts.zip (vs), gfx, txt)
	.color (blue*white)
	.title (`velocity`)
	, square (0.15)
);

this compiles:
flight_info.add (Plot (ts.zip (vs), gfx, txt), square (0.15));

this also compiles:
auto plot = Plot (ts.zip (vs), gfx, txt);
flight_info.add (plot
	.color (blue*white)
	, square (0.15)
);

but this will not:
auto plot = Plot (ts.zip (vs), gfx, txt);
flight_info.add (plot
	.color (blue*white)
	.title (`velocity`)
	, square (0.15)
);

For clarification, the Plot constructor (and all of its 
option-setting functions) return a copy of the Plot with the new 
option set. It looks like when I pass it through more than one 
layer of "return this" inside of the function arguments for 
flight_info.add, it triggers the backend/cgcs.c assertion.
Jun 14 2014
parent "Vlad Levenfeld" <vlevenfeld gmail.com> writes:
I'd also like to note that elsewhere in my code (in a unittest to 
be precise), I am using the full functionality of the Plot struct 
with no hiccups...

info.add (
	Plot (ℕ!24.map!(i => 0.8*i)
		.map!(x => τ(x, sin (x^^2))),
	gfx, txt)
		.title (`testing`)
		.y_axis (`output`, Plot.Range (-1, 1))
		.x_axis (`input`)
		.text_size (8)
		.color (blue * white),
	square (0.5).map!(v => v*vec(1.2,1))
)	.align_to (Alignment.top_right)
	.decorate ((Bounding_Box bounds){gfx.draw (blue.alpha (0.5), 
bounds);});

This compiles and runs without issues even though it is using 
even more of the thing that made the other examples fail, in the 
exact same sort of context.
Jun 14 2014
prev sibling parent reply "Kapps" <opantm2+spam gmail.com> writes:
Possibly https://issues.dlang.org/show_bug.cgi?id=11763 or
https://issues.dlang.org/show_bug.cgi?id=11903
Jun 16 2014
parent "Vlad Levenfeld" <vlevenfeld gmail.com> writes:
I ran the program suggested by H.S. Teoh and the reduced code 
looks very similar
#11763.

I've submitted the bug at 
https://issues.dlang.org/show_bug.cgi?id=12926
Jun 16 2014