[Issue 7056] New: weird segfault in std.conv.to

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 2 13:39:05 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=7056

           Summary: weird segfault in std.conv.to
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: mrmocool at gmx.de


--- Comment #0 from Trass3r <mrmocool at gmx.de> 2011-12-02 13:37:56 PST ---
import std.conv;
import std.math;

void main()
{
    import std.stdio;
    vec3 w = vec3();
    writefln("%f w: %f", 3.5f, w.length);
}

struct Vector(T, int dim)
{
    union
    {
        struct
        {
            T x = 0;
            T y = 0;
            T z = 0;
        }
        T[dim] cell;
    }

    string toString()     {
        return to!string(cell);
    }

    /// return length*length
    @property T sqLength()
    {
        return cast()x * x + y * y + z * z;
    }

    /// return the vector length
    @property T length()     {
        toString;
        auto ret = sqLength;
        return sqrt(ret);
    }

}

alias Vector!(float, 3)    vec3;


$ dmd -debug -gc vector.d && gdb --batch -ex 'run' -ex 'bt 15' ./vector
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7669faa in snprintf () from /lib/x86_64-linux-gnu/libc.so.6
#0  0x00007ffff7669faa in snprintf () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000000000044affe in void
std.format.formatValue!(std.array.Appender!(immutable(char)[]).Appender, float,
char).formatValue(std.array.Appender!(immutable(char)[]).Appender, float, ref
std.format.FormatSpec!(char).FormatSpec) (f=0x7fffffffdcd8, obj=0, w=...) at
/home/trass3r/coding/dmd/linux/bin64/../../src/phobos/std/format.d:1204
#2  0x000000000044b387 in void
std.format.formatElement!(std.array.Appender!(immutable(char)[]).Appender,
float, char).formatElement(std.array.Appender!(immutable(char)[]).Appender,
float, ref std.format.FormatSpec!(char).FormatSpec) (f=0x7fffffffdcd8, val=0,
w=...) at
/home/trass3r/coding/dmd/linux/bin64/../../src/phobos/std/format.d:1596
#3  0x000000000044a661 in void
std.format.formatRange!(std.array.Appender!(immutable(char)[]).Appender,
float[], char).formatRange(std.array.Appender!(immutable(char)[]).Appender,
float[], ref std.format.FormatSpec!(char).FormatSpec) (f=0x7fffffffdcd8,
val=0x00007fffffffdd780000000000000003, w=...) at
/home/trass3r/coding/dmd/linux/bin64/../../src/phobos/std/format.d:1452
#4  0x000000000044a50f in void
std.format.formatValue!(std.array.Appender!(immutable(char)[]).Appender,
float[], char).formatValue(std.array.Appender!(immutable(char)[]).Appender,
float[], ref std.format.FormatSpec!(char).FormatSpec) (f=0x7fffffffdcd8,
val=0x00007fffffffdd780000000000000003, w=...) at
/home/trass3r/coding/dmd/linux/bin64/../../src/phobos/std/format.d:1386
#5  0x000000000044a4dd in immutable(char)[] std.conv.toStr!(immutable(char)[],
float[]).toStr(float[]) (src=0x00007fffffffdd780000000000000003) at
/home/trass3r/coding/dmd/linux/bin64/../../src/phobos/std/conv.d:94
#6  0x000000000044a48f in immutable(char)[] std.conv.toImpl!(immutable(char)[],
float[]).toImpl(float[]) (s=0x00007fffffffdd780000000000000003) at
/home/trass3r/coding/dmd/linux/bin64/../../src/phobos/std/conv.d:803
#7  0x000000000044a401 in immutable(char)[] std.conv.toImpl!(immutable(char)[],
float[3]).toImpl(ref float[3]) (s=0x7fffffffdd78) at
/home/trass3r/coding/dmd/linux/bin64/../../src/phobos/std/conv.d:353
#8  0x000000000044a381 in immutable(char)[]
std.conv.to!(immutable(char)[]).to!(float[3]).to(float[3]) (_param_0=...) at
/home/trass3r/coding/dmd/linux/bin64/../../src/phobos/std/conv.d:237
#9  0x0000000000442d3f in immutable(char)[] vector.Vector!(float,
3).Vector.toString() (this=0x7fffffffde10) at vector.d:25
#10 0x0000000000442df6 in @property float vector.Vector!(float,
3).Vector.length() (this=0x7fffffffde10) at vector.d:36

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list