www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20042] New: __vector CTFE crashes the compiler

https://issues.dlang.org/show_bug.cgi?id=20042

          Issue ID: 20042
           Summary: __vector CTFE crashes the compiler
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: thomas.bockman gmail.com

import std.stdio;

struct Vec4 {
    __vector(float[4]) raw;

    this(const(float[4]) value...) inout pure  safe nothrow  nogc {
        __vector(float[4]) raw;
        raw[] = value[];
        this.raw = raw;
    }
}

void main() {
    static immutable Vec4 v = Vec4(  1.0f, 2.0f, 3.0f, 4.0f );

    static foreach(d; 0 .. 4)
        write(v.raw[d], " ");
}

Attempting to compile the above yields "Illegal instruction (core dumped)".
Removing the `static immutable` makes everything work as expected.

--
Jul 10 2019