From 7444be452ddf43ce2e1227427ccf67b3de620b01 Mon Sep 17 00:00:00 2001 From: k-hara Date: Thu, 10 Apr 2014 16:29:49 +0900 Subject: [PATCH] fix Issue 11906 - Compiler assertion when comparing function pointers If `f->isImportedSymbol()` is true, the translation from `AddrExp(VarExp(f))` to `SymOffExp(f)` in `AddrExp::optimize` will be skipped. Therefore, the assertion is just wrong. --- src/cast.c | 2 +- test/compilable/ice11906.d | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/compilable/ice11906.d diff --git a/src/cast.c b/src/cast.c index 87d5167c6a5d..ea5731218081 100644 --- a/src/cast.c +++ b/src/cast.c @@ -1800,7 +1800,7 @@ Expression *castTo(Expression *e, Scope *sc, Type *t) FuncDeclaration *f = ve->var->isFuncDeclaration(); if (f) { - assert(0); // should be SymOffExp instead + assert(f->isImportedSymbol()); f = f->overloadExactMatch(tb->nextOf()); if (f) { diff --git a/test/compilable/ice11906.d b/test/compilable/ice11906.d new file mode 100644 index 000000000000..f568701b4635 --- /dev/null +++ b/test/compilable/ice11906.d @@ -0,0 +1,10 @@ +// REQUIRED_ARGS: -o- +// PERMUTE_ARGS: + +nothrow /*extern(Windows) */export int GetModuleHandleA(const char* lpModuleName); + +void main() +{ + /*extern(Windows) */int function(const char*) f; + assert(f != &GetModuleHandleA); +}