Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 143 - ICE, segfaults, apparently the compiler doesn't like the "%s" string when reporting error
Summary: ICE, segfaults, apparently the compiler doesn't like the "%s" string when rep...
Status: RESOLVED FIXED
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: 4.9.x
Hardware: All All
: --- normal
Assignee: Iain Buclaw
URL:
Depends on:
Blocks:
 
Reported: 2014-07-20 20:23 CEST by art.08.09
Modified: 2014-07-21 12:16 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description art.08.09 2014-07-20 20:23:26 CEST
template f(A) {}
void g(A)(A);
f!({g("%s");}) _;

causes:

cc1d: internal compiler error: Segmentation fault
0xa81fef crash_signal
	../../gcc/toplev.c:337
0x6e53eb verror(Loc, char const*, __va_list_tag*, char const*, char const*, char const*)
	../../gcc/d/d-glue.cc:191
0x5b094d Dsymbol::error(char const*, ...)
	../../gcc/d/dfrontend/dsymbol.c:633
0x68e723 TemplateInstance::findBestMatch(Scope*, Array<Expression*>*)
	../../gcc/d/dfrontend/template.c:6377
0x692cf8 TemplateInstance::semantic(Scope*, Array<Expression*>*)
	../../gcc/d/dfrontend/template.c:5317
0x692cf8 TemplateInstance::semantic(Scope*)
	../../gcc/d/dfrontend/template.c:5202
0x6404fa TypeInstance::resolve(Loc, Scope*, Expression**, Type**, Dsymbol**, bool)
	../../gcc/d/dfrontend/mtype.c:7284
0x6404fa TypeInstance::semantic(Loc, Scope*)
	../../gcc/d/dfrontend/mtype.c:7301
0x5a27c9 VarDeclaration::semantic(Scope*)
	../../gcc/d/dfrontend/declaration.c:884
0x649fbd Module::semantic()
	../../gcc/d/dfrontend/module.c:744
0x69d293 d_parse_file()
	../../gcc/d/d-lang.cc:1007
Please submit a full bug report,
Comment 1 Iain Buclaw 2014-07-21 10:31:45 CEST
Can not reproduce on current master.  I get:


bug143.d:3: error: template instance f!(function ()
{
g("f(A)");
}
) does not match template declaration (null)
Comment 2 art.08.09 2014-07-21 11:50:09 CEST
(In reply to Iain Buclaw from comment #1)
> Can not reproduce on current master.  I get:
> 
> bug143.d:3: error: template instance f!(function ()
> {
> g("f(A)");
> }
> ) does not match template declaration (null)

I only ran into this while reducing another testcase, so I don't have a better example. Note that it crashes _only_ when that string literal contains "%s" (or '%' followed by other chars), it seems that it tries to interpret it as a format string.
If the output you got was from the original unmodified testcase then the error message is bogus - there's no "f(A)" string there. (That 'null' would also be an issue; IIRC I've seen that here too, while trying to figure out what was triggering the crash)
Comment 3 Iain Buclaw 2014-07-21 12:16:49 CEST
Ah right, I didn't bother reading the *actual* message contents.