[Bug c++/72756] Using an enum as a constant expression via dot operator should not compile.

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 2 03:44:32 GMT 2021


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=79083
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |accepts-invalid
   Last reconfirmed|                            |2021-08-02

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is the full testcase (since it needs tested at instantation time):
#include <stddef.h>
template<size_t n> struct A{};

template<size_t n>
struct tst
{   enum : size_t { m= n % 15 };

    template<size_t p>
    void
    call( tst<p> const &t2 ) {
        A<t2.m>  a; // 1
    }
};


int main(void)
{
    tst<0> t;
    tst<1> t1;
    t.call(t1);
}

------ CUT ----

Confirmed.  Also related to PR 79083.

Note:
GCC, ICC and MSVC all accept the code
clang rejects the code.

Note they all accept the code without doing an instantation of the function
though.


More information about the Gcc-bugs mailing list