problem: address space attribute C/C++

Hi,

I have a problem with clang and the address space attribute. I don’t know if it is intended or a bug. The following code compiles fine as a .c file but fails as .cpp:

C-Code:
int attribute((address_space(1))) globalint = 10;

bitcode:
@globalint = addrspace(1) global i32 10, align 4 ; <i32 addrspace(1)*> [#uses=0]

Error in clangtest.cpp:
clangtest.cpp:2:39: error: cannot initialize a variable of type ‘int
attribute((address_space(1)))’ with an rvalue of type ‘int’
int attribute((address_space(1))) globalint = 10;
^ ~~
1 error generated.

I have additional problems with classes. In which cases are none zero address spaces supported, is there a documentation around?

thanks in advance,
Helge

Hi,

I have a problem with clang and the address space attribute. I don’t know if it is intended or a bug. The following code compiles fine as a .c file but fails as .cpp:

C-Code:
int attribute((address_space(1))) globalint = 10;

bitcode:
@globalint = addrspace(1) global i32 10, align 4 ; <i32 addrspace(1)*> [#uses=0]

Error in clangtest.cpp:
clangtest.cpp:2:39: error: cannot initialize a variable of type ‘int
attribute((address_space(1)))’ with an rvalue of type ‘int’
int attribute((address_space(1))) globalint = 10;
^ ~~
1 error generated.

That’s definitely a bug. Please file a bug at llvm.org, or (better yet!) provide a patch.

I have additional problems with classes. In which cases are none zero address spaces supported, is there a documentation around?

Not much. Address spaces are described in the Embedded C TR; the draft of that TR (which has since been published) is available at http://www.open-std.org/jtc1/sc22/wg14/www/projects.

  • Doug