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

            Bug ID: 94597
           Summary: ICE while using a concept checking for user defined
                    conversion operator
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barolek at gmail dot com
  Target Milestone: ---

Hello,

I found this ICE when playing with Godbolt compiler explorer. I don't have
access to system with installed GCC, I can't get preprocessed file (as in
instruction), I will give the source code, that caused the error.

Following snipped caused ICE on GCC, it compiles with Clang, I think (concepts
are new feature and I'm not expert) that this is a valid code which should
accept types with defined user defined conversion operator.

GCC INFO:

COLLECT_GCC=/opt/compiler-explorer/gcc-snapshot/bin/g++

Target: x86_64-linux-gnu

Configured with: ../gcc-trunk-20200414/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu --enable-languages=c,c++,fortran,ada,d
--enable-ld=yes --enable-gold=yes --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto
--enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build

Thread model: posix

Supported LTO compression algorithms: zlib

gcc version 10.0.1 20200413 (experimental) (Compiler-Explorer-Build) 

COMPILER FLAGS: -std=c++2a

SOURCE CODE: (https://godbolt.org/z/33LD8M) (It compiles with clang trunk with
-stdlib=libc++ flag)

#include <concepts>

template<typename From, typename To>
concept has_user_defined_conversion = requires (From f)
{
    f.operator To();
};

template<typename w, typename w2>
requires (has_user_defined_conversion<w, w2>)
        bool equal(w const& x, w2 const& y)
        {
                return x == y;
        }

template <typename T>
struct wrapper
{
    T f;

    wrapper(T a) : f(a) {}

    operator T() const
    {
        return f;
    }
};

bool fun()
{
    wrapper a(2.0f);
    wrapper b(3.0f);

    return equal(a, 3.0f);
}

Reply via email to