circle icon indicating copy to clipboard operation
circle copied to clipboard

Segmentation fault with union and constexpr

Open gogoprog opened this issue 1 year ago • 2 comments

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

gogoprog avatar Dec 21 '23 20:12 gogoprog

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); }));
}

mingodad avatar Jan 01 '24 21:01 mingodad

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

typedef union {
} a;
a b{};

iphydf avatar Jan 20 '24 19:01 iphydf