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

            Bug ID: 90711
           Summary: Failing SFINAE from unrelated struct
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: da_cra_hunt at yahoo dot com
  Target Milestone: ---

Created attachment 46443
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46443&action=edit
Temporary from error case

I've run into a strange situation where a nominally unrelated type using
detection with void_t causes a change in the behavior of a second type :

---
dhunt@eoan-vm:/tmp$ cat lk.cpp
#include <type_traits>
#include <iostream>
#include <string>

#if !defined(SUPPRESS)
  template<typename O, typename = void>
  struct has_to_string : public std::false_type {};

  template<typename O>
  struct has_to_string<O, std::void_t<decltype(
      to_string(std::declval<O>()))>> : public std::true_type {};
#endif

  template<typename O, typename = void>
  struct has_std_to_string : public std::false_type {};

  template<typename O>
  struct has_std_to_string<O, std::void_t<decltype(
      std::to_string(std::declval<O>()))>> : public std::true_type {};

int main(int argc, char *argv[]) {
#if 0
  to_string(90);
  std::to_string(90);
#endif
  std::cout << "int : " << has_std_to_string<int>::value << std::endl;
}
dhunt@eoan-vm:/tmp$ g++-9 -std=c++17 -DSUPPRESS ./lk.cpp ; ./a.out
int : 1
dhunt@eoan-vm:/tmp$ g++-9 -std=c++17 ./lk.cpp ; ./a.out
int : 0
dhunt@eoan-vm:/tmp$ g++-9 -v
Using built-in specs.
COLLECT_GCC=g++-9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.1.0-2ubuntu2'
--with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 9.1.0 (Ubuntu 9.1.0-2ubuntu2) 

---

The above OS is a VirtualBox VM running the Ubuntu Nightly Server from
2019-05-25. I'm not making any claims that the above is the right way to
implement; it is simply meant to illustrate the behavior.

ALSO PRODUCES "int : 0": godbolt gcc trunk (20190601), gobolt gcc 9.1
PRODUCES "int : 1": Ubuntu Bionic gcc 7.4, godbolt gcc 8.3, godblot clang
trunk, godbolt clang 8.0.0, godbolt clang 7.0.0

Reply via email to