Public bug reported:
With the build of GCC available in ubuntu 18.04, I get the following
error when trying to compile this code:
// minimal example to break gcc 7 in the same way that the reflect code breaks
it
#include <type_traits>
template<class T, class R, class ... ARGS>
struct MemberPointer
{
R (T::* ptr)(ARGS...);
};
template<class T, class R, class ... ARGS>
constexpr MemberPointer<T, R, ARGS...> makeMemberPointer(R(T::* ptr)(ARGS...))
{
return {ptr};
}
struct Foo
{
static constexpr auto getField(std::integral_constant<int, 0>)
{
// This line breaks gcc
return makeMemberPointer(static_cast<void(Foo::*)()>(&Foo::foo));
// This line does not break gcc
//return makeMemberPointer(&Foo::foo);
}
void foo(){}
};
template<class T>
struct Wrapper
{
template<int I>
static constexpr auto getField()
{
return T::getField(std::integral_constant<int, I>{});
}
};
int main()
{
// This line works fine either way
Foo::getField(std::integral_constant<int, 0>{});
// The offending line only breaks gcc when called through the Wrapper class
Wrapper<Foo>::getField<0>();
}
error:
internal compiler error: in fold_convert_loc, at fold-const.c:2530
return T::getField(std::integral_constant<int, I>{});
Interestingly enough this bug is not present when I put this code into godbolt
(https://godbolt.org/) which would indicate that it might be a difference in
how the compilers were built.
The different flags between godbolt and ubuntu's built of gcc are as follows:
godbolt:
Configured with: ../gcc-7.4.0/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --disable-bootstrap
--enable-clocale=gnu --enable-languages=c,c++,fortran --enable-ld=yes
--enable-gold=yes --enable-lto --enable-plugins
--with-pkgversion=GCC-Explorer-Build
ubuntu:
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --libexecdir=/usr/lib
--without-included-gettext --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx
--enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib --enable-objc-gc=auto --disable-werror
--with-arch-32=i686 --with-tune=generic --enable-offload-targets=nvptx-none
--without-cuda-driver --enable-checking=release
** Affects: gcc-7 (Ubuntu)
Importance: Undecided
Status: New
** Description changed:
With the build of GCC available in ubuntu 18.04, I get the following
error when trying to compile this code:
// minimal example to break gcc 7 in the same way that the reflect code
breaks it
#include <type_traits>
template<class T, class R, class ... ARGS>
struct MemberPointer
{
- R (T::* ptr)(ARGS...);
+ R (T::* ptr)(ARGS...);
};
template<class T, class R, class ... ARGS>
constexpr MemberPointer<T, R, ARGS...> makeMemberPointer(R(T::* ptr)(ARGS...))
{
- return {ptr};
+ return {ptr};
}
struct Foo
{
- static constexpr auto getField(std::integral_constant<int, 0>)
- {
- return makeMemberPointer(static_cast<void(Foo::*)()>(&Foo::foo)); //
This line breaks gcc
- //return makeMemberPointer(&Foo::foo); //
This line does not break gcc
- }
+ static constexpr auto getField(std::integral_constant<int, 0>)
+ {
+ // This line breaks gcc
+ return makeMemberPointer(static_cast<void(Foo::*)()>(&Foo::foo));
- void foo(){}
+ // This line does not break gcc
+ //return makeMemberPointer(&Foo::foo);
+ }
+
+ void foo(){}
};
template<class T>
struct Wrapper
{
- template<int I>
- static constexpr auto getField()
- {
- return T::getField(std::integral_constant<int, I>{});
- }
+ template<int I>
+ static constexpr auto getField()
+ {
+ return T::getField(std::integral_constant<int, I>{});
+ }
};
int main()
{
- Foo::getField(std::integral_constant<int, 0>{}); // This line works fine
either way
- Wrapper<Foo>::getField<0>(); // The offending line only breaks gcc when
called through the Wrapper class
+ // This line works fine either way
+ Foo::getField(std::integral_constant<int, 0>{});
+ // The offending line only breaks gcc when called through the Wrapper class
+ Wrapper<Foo>::getField<0>();
}
+ error:
+ internal compiler error: in fold_convert_loc, at fold-const.c:2530
+ return T::getField(std::integral_constant<int, I>{});
- error:
- internal compiler error: in fold_convert_loc, at fold-const.c:2530
- return T::getField(std::integral_constant<int, I>{});
-
- Interestingly enough this bug is not present when I put this code into
godbolt (https://godbolt.org/) which would indicate that it might be a
difference in how the compilers were built.
+ Interestingly enough this bug is not present when I put this code into
godbolt (https://godbolt.org/) which would indicate that it might be a
difference in how the compilers were built.
The different flags between godbolt and ubuntu's built of gcc are as follows:
- godbolt:
+ godbolt:
Configured with: ../gcc-7.4.0/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --disable-bootstrap
--enable-clocale=gnu --enable-languages=c,c++,fortran --enable-ld=yes
--enable-gold=yes --enable-lto --enable-plugins
--with-pkgversion=GCC-Explorer-Build
ubuntu:
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --libexecdir=/usr/lib
--without-included-gettext --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx
--enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib --enable-objc-gc=auto --disable-werror
--with-arch-32=i686 --with-tune=generic --enable-offload-targets=nvptx-none
--without-cuda-driver --enable-checking=release
** Description changed:
With the build of GCC available in ubuntu 18.04, I get the following
error when trying to compile this code:
// minimal example to break gcc 7 in the same way that the reflect code
breaks it
#include <type_traits>
template<class T, class R, class ... ARGS>
struct MemberPointer
{
R (T::* ptr)(ARGS...);
};
template<class T, class R, class ... ARGS>
constexpr MemberPointer<T, R, ARGS...> makeMemberPointer(R(T::* ptr)(ARGS...))
{
return {ptr};
}
struct Foo
{
static constexpr auto getField(std::integral_constant<int, 0>)
{
- // This line breaks gcc
- return makeMemberPointer(static_cast<void(Foo::*)()>(&Foo::foo));
+ // This line breaks gcc
+ return makeMemberPointer(static_cast<void(Foo::*)()>(&Foo::foo));
// This line does not break gcc
- //return makeMemberPointer(&Foo::foo);
- }
+ //return makeMemberPointer(&Foo::foo);
+ }
void foo(){}
};
template<class T>
struct Wrapper
{
template<int I>
static constexpr auto getField()
{
return T::getField(std::integral_constant<int, I>{});
}
};
int main()
{
- // This line works fine either way
- Foo::getField(std::integral_constant<int, 0>{});
- // The offending line only breaks gcc when called through the Wrapper class
- Wrapper<Foo>::getField<0>();
+ // This line works fine either way
+ Foo::getField(std::integral_constant<int, 0>{});
+ // The offending line only breaks gcc when called through the Wrapper class
+ Wrapper<Foo>::getField<0>();
}
error:
internal compiler error: in fold_convert_loc, at fold-const.c:2530
return T::getField(std::integral_constant<int, I>{});
Interestingly enough this bug is not present when I put this code into
godbolt (https://godbolt.org/) which would indicate that it might be a
difference in how the compilers were built.
The different flags between godbolt and ubuntu's built of gcc are as follows:
godbolt:
Configured with: ../gcc-7.4.0/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --disable-bootstrap
--enable-clocale=gnu --enable-languages=c,c++,fortran --enable-ld=yes
--enable-gold=yes --enable-lto --enable-plugins
--with-pkgversion=GCC-Explorer-Build
ubuntu:
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --libexecdir=/usr/lib
--without-included-gettext --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx
--enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib --enable-objc-gc=auto --disable-werror
--with-arch-32=i686 --with-tune=generic --enable-offload-targets=nvptx-none
--without-cuda-driver --enable-checking=release
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1829790
Title:
internal compiler arror in fold_convert_loc
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1829790/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs