llvm-mos
llvm-mos copied to clipboard
Fail to compile uninitialized zeropage structs
The following fails to compile (live example):
struct Foo {
int x;
};
// works
__zeropage Foo bar{0};
// fails
__zeropage Foo foo;
<source>:9:16: error: no matching constructor for initialization of '__attribute__((address_space(1))) Foo'
9 | __zeropage Foo foo;
| ^
<source>:1:8: note: candidate constructor ignored: cannot be used to construct an object in address space '__attribute__((address_space(1)))'
1 | struct Foo {
| ^
<source>:1:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
1 | struct Foo {
| ^~~
<source>:1:8: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided
1 | struct Foo {
| ^~~
1 error generated.
Compiler returned: 1
This is a C++-specific issue. As far as I understand, the default constructors Clang generates for a struct type assume the default address space and thus fail to operate in a non-standard address space.
This is a known Clang issue (per clang/test/SemaCXX/address-space-ctor.cpp), and would necessitate a fix upstream:
// FIXME: We can't implicitly convert between address spaces yet.