[Bug 1829790] Re: internal compiler arror in fold_convert_loc

Matthias Klose doko at ubuntu.com
Tue May 21 10:02:42 UTC 2019


** Also affects: gcc-9 (Ubuntu)
   Importance: Undecided
       Status: New

** Changed in: gcc-9 (Ubuntu)
       Status: New => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-7 in Ubuntu.
https://bugs.launchpad.net/bugs/1829790

Title:
  internal compiler arror in fold_convert_loc

Status in gcc-7 package in Ubuntu:
  Confirmed
Status in gcc-9 package in Ubuntu:
  Fix Released

Bug description:
  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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1829790/+subscriptions



More information about the foundations-bugs mailing list