Skip to content

Commit

Permalink
fix Issue 11906 - Compiler assertion when comparing function pointers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
9rnsr committed Apr 10, 2014
1 parent 776a542 commit 7444be4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cast.c
Expand Up @@ -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)
{
Expand Down
10 changes: 10 additions & 0 deletions 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);
}

0 comments on commit 7444be4

Please sign in to comment.