digitalmars.D.learn - An array()/map inlining problem
- bearophile <bearophileHUGS lycos.com> Sep 07 2010
- Jonathan M Davis <jmdavisprog gmail.com> Sep 07 2010
- bearophile <bearophileHUGS lycos.com> Sep 08 2010
This is interesting, if you compile it with:
dmd test.d
It works. If you compile it with:
dmd -inline test.d
It doesn't compile and dmd returns:
test.d(5): Error: function D main is a nested function and cannot be accessed
from array
import std.algorithm: map;
import std.array: array;
void main() {
int c;
array(map!((x){return c;})([1]));
}
I think this is a compiler bug, right (because I think it must not compile in
both cases or compile in both)?
Bye,
bearophile
Sep 07 2010
On Tuesday 07 September 2010 19:58:01 bearophile wrote:This is interesting, if you compile it with: dmd test.d It works. If you compile it with: dmd -inline test.d It doesn't compile and dmd returns: test.d(5): Error: function D main is a nested function and cannot be accessed from array import std.algorithm: map; import std.array: array; void main() { int c; array(map!((x){return c;})([1])); } I think this is a compiler bug, right (because I think it must not compile in both cases or compile in both)? Bye, bearophile
Inlining should _never_ affect the compilability of a program. It should be essentially invisible to programmer. It might be visible if you examined the actual assembly or resultant binary, and hopefully -inline makes your program faster, but what errors you do or don't get and the semantics of your program should be identical. This is most definitely a bug. - Jonathan M Davis
Sep 07 2010
Jonathan M Davis:Inlining should _never_ affect the compilability of a program. It should be essentially invisible to programmer. It might be visible if you examined the actual assembly or resultant binary, and hopefully -inline makes your program faster, but what errors you do or don't get and the semantics of your program should be identical. This is most definitely a bug.
http://d.puremagic.com/issues/show_bug.cgi?id=4841 Bye, berarophile
Sep 08 2010








bearophile <bearophileHUGS lycos.com>