seanbaxter / circle

The compiler is available for download. Get it!
http://www.circle-lang.org/
2.42k stars 74 forks source link

Segmentation fault with union and constexpr #195

Open gogoprog opened 11 months ago

gogoprog commented 11 months ago

Hello,

I encountered a segmentation fault when compiling code involving constexpr and union. Here is the minimal reproducible case :

#include <array>

struct Coord {
    union {
        struct {
            int x;
            int y;
        };
        struct {
            int first;
            int second;
        };
    };
};

constexpr std::array<Coord, 4> dirs = {Coord{0, -1}, {1, 0}, {0, 1}, {-1, 0}};

int main() {
    return 0;
}

If the union or the constexpr is removed, the compilation becomes functional.

circle version 1.0.0-200
  Circle public preview build 200
  Built Jul 29 2023 11:15:57 EDT
mingodad commented 10 months ago

Also segfault with the sample shown bellow see discussion here https://github.com/robertoraggi/cplusplus/issues/311 .

void test()
{
    int i;
    ( ({ long __cpu = ((long) i); }));
}
iphydf commented 10 months ago

Any union seems to segfault the compiler. Minimal repro (creduce'd from actual code):

typedef union {
} a;
a b{};