std.algorithm Map using a external variable

Maxim Fomin maxim at maxim-fomin.ru
Mon Dec 10 11:03:42 PST 2012


On Monday, 10 December 2012 at 18:21:48 UTC, Zardoz wrote:
> I'm trying to use Map with a code like this :
>
> ...
>   immutable int m = 10;
>   int[] caca = [1,2,3,4];
>
>   auto caca2 = map!( (a) {return a * m;})(caca);
>
>   writeln(caca2);
> ...
>
> I get a Segmentation fault some times:
> The most interesting point it's that depends of the code around 
> of it ins the same  program. for example If a use getopt at the 
> begin of my program, then seg fault, etc...
>  Looks that there some weird error in gdc 4.6.3
>
> PD: Later I will put the whole code so any can see if I doing 
> some weird thing that make map crazy

Looks like template lambda bug 
(http://d.puremagic.com/issues/show_bug.cgi?id=8899). It might 
depend not only on surrounding code, but on importing some phobos 
module (issue 8854).


More information about the Digitalmars-d-learn mailing list