llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.8k stars 11.45k forks source link

Pointer-to-member does not honor LHS address space #26315

Open llvmbot opened 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 25941
Version trunk
OS All
Attachments Bug test case, Patch solving issue
Reporter LLVM Bugzilla Contributor
CC @dhebbeker,@DougGregor

Extended Description

The lvalue resulting from pointer-to-member operators . and -> is always in address space 0, without regards to the address space of the left-hand value; see attached test.cpp file for a test case.

arsenm commented 1 year ago

Looks broken:

test.cpp:10:14: error: cannot initialize a variable of type 'AS1 int *' with an rvalue of type 'int *'
   10 |     int AS1* x = &(f->*(&foo::bar));
      |              ^   ~~~~~~~~~~~~~~~~~~
llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-frontend

Endilll commented 1 year ago

Compiler explorer link for the previous comment: https://godbolt.org/z/4v3fzv4rj

shafik commented 1 year ago

code:

struct foo {
    int bar;
};

#define AS1 __attribute__((address_space(1)))

int main()
{
    foo AS1* f;
    int AS1* x = &(f->*(&foo::bar));
}