Skip to content

Commit

Permalink
Functions with identical bodies are allowed to be merged by compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
H. S. Teoh committed Oct 30, 2014
1 parent 633f656 commit b9c31c6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions function.dd
Expand Up @@ -1740,6 +1740,21 @@ void bar()
test();
int i = fp(); // i is set to 10
}
------

$(P $(B Note:) Two functions with identical bodies, or two functions
that compile to identical assembly code, are not guaranteed to have
distinct function pointer values. The compiler is free to merge
functions bodies into one if they compile to identical code.)

------
int abc(int x) { return x + 1; }
int def(int y) { return y + 1; }

int function() fp1 = &abc;
int function() fp2 = &def;
// Do not rely on fp1 and fp2 being different values; the compiler may merge
// them.
------

$(P A delegate can be set to a non-static nested function:)
Expand Down

0 comments on commit b9c31c6

Please sign in to comment.