5932 – Internal error: s2ir.c 339

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5932 - Internal error: s2ir.c 339
Summary: Internal error: s2ir.c 339
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
Reported: 2011年05月05日 16:07 UTC by Walter Bright
Modified: 2015年06月09日 05:10 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2011年05月05日 16:07:36 UTC
Compiling the code:
--------------------------
void checkops(T...)( T ops ) {
 static assert( 0 );
}
void receive(T...)( T ops ) {
 checkops( ops );
 get( ops );
}
void get(T...)( T vals ) {
 void onStandardMsg() {
 foreach( t; T )
 {
 }
 }
}
void test() {
 assert( !__traits( compiles,
 {
 receive( (long x) {}, (int x) {} );
 } ) );
}
-------------------------
Produces the error:
Internal error: s2ir.c 339
What's likely happening is semantic() is not run on onStandardMsg(), which is likely caused by the __traits(compile failing, and yet marking semantic() as having been run.
Comment 1 Don 2011年05月06日 01:47:34 UTC
This is probably related to bug 4910, and also to bug 4269 ("invalid type accepted if evaluated while errors are gagged")
There's a problem with the gagging system.
One difficulty is that if there has been a forward reference, CTFE needs to run semantic3 on the function. If errors are gagged from inside VarDeclaration::semantic, the gagging should only apply to CTFE; the semantic3 errors should not be gagged.
The problem is, the gagging system doesn't have any mechanism for ungagging.
If we instantiated a template from inside is(typeof()), semantic errors should be gagged; we don't yet know if the template will be instantiated. Let's call this an investigative template instantiation. This is recursive; any template instantiated from inside a investigative template is also investigative.
BUT, any semantic run on anything other than a investigative template should NOT be gagged. The simple incrementing and decrementing of global.gag doesn't quite work.
The other side of the problem is bug 4269: failed templates are not removed. If there is an attempt to instantiate them from a non-gagged state, the original (previously suppressed) error messages should be shown.
Comment 2 Don 2011年09月15日 07:46:34 UTC
Reduced test case fails also on D1.070 (again with ICE(s2ir.c).
On D2.054 and later, this test case hits bug 6675 ICE(glue.c) instead.
======
void receive(T)() {
 static assert( 0 );
 get( 7 );
}
void get(T)( T val ) {
 void onStandardMsg() {
 foreach( t; T ) { }
 }
}
static assert(!is(typeof(
 {
 receive!(int)();
 }()
)));


AltStyle によって変換されたページ (->オリジナル) /