https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117849

Barry Revzin <barry.revzin at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |barry.revzin at gmail dot com

--- Comment #12 from Barry Revzin <barry.revzin at gmail dot com> ---
I'm not sure this is quite right yet. This is on gcc trunk on compiler explorer
right now, which is g++
(Compiler-Explorer-Build-gcc-8fbe7d24373556d40886c7c00e9e2be5d9718c55-binutils-2.42)
15.0.1 20250407 (experimental):

template <class T, int N>
struct Array {
    constexpr int size() const { return N; }
};

struct A {
    Array<int, 4> a;

    void f() {
        static_assert(a.size() == 4); // ok
    }        
};

struct B {
    Array<int, 4>* p;

    void f() {
        static_assert(p->size() == 4); // error (expected) 
    }    
};

struct C {
    Array<int, 4>& r;

    void f() {
        static_assert(r.size() == 4); // error (unexpected?)
    }
};

struct D {
    Array<int, 4>& r;

    void f() {
        Array<int, 4>& local = r;
        static_assert(local.size() == 4); // error (unexpected?)
    }
};

The A case works as expected, and the B case fails as expected (we didn't add
pointers to unknown, just references to unknown). But the C and D cases both
fail, and I would have expected them to succeed.

Reply via email to