LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 41561 - decltype(&(C::member)) yields pointer-to-member type
Summary: decltype(&(C::member)) yields pointer-to-member type
Status: CONFIRMED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-22 14:55 PDT by Máté Cserna
Modified: 2021-02-10 07:34 PST (History)
9 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Máté Cserna 2019-04-22 14:55:24 PDT
In some contexts, decltype(&(C::member)) yields a pointer to member type, but according to [expr.unary.op]/4, no pointer to member should be formed when the operand of the & operator is enclosed in parentheses.

http://eel.is/c++draft/expr.unary.op#4

The code below demonstrates this behavior. It compiles on all Clang versions I have tried between 3.2 and HEAD, even though I don't think it should.

```
#include <type_traits>
 
struct S {
    int x;

    static_assert(std::is_same<decltype(&(S::x)), int S::*>::value, ""); // !

    void foo() {
        static_assert(std::is_same<decltype(&(S::x)), int*>::value, ""); // OK
    }
};

static_assert(std::is_same<decltype(&(S::x)), int S::*>::value, ""); // !

int main() {
}
```