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

            Bug ID: 109606
           Summary: Unguarded `__is_same` builtin usage
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: akaraevz at mail dot ru
  Target Milestone: ---

Hello.

This commit
(https://github.com/gcc-mirror/gcc/commit/17855eed7fc76b2cee7fbbc26f84d3c8b99be13c)
introduces new helper function `__find_uniq_type_in_pack` that uses `__is_same`
builtin. However, this builtin is only supported since gcc-10. There's no
`#ifdef`-guard so this code won't compile using gcc-9 or any other compiler
that doesn't provide `__is_same` builtin. Is it expected behaviour?

In contrast, current implementation of `std::is_same`
(https://github.com/gcc-mirror/gcc/blob/b98c63e9e8ceaf9e04c28d83500f98313284c7f8/libstdc%2B%2B-v3/include/std/type_traits#L1392-L1406)
correctly checks for `_GLIBCXX_HAVE_BUILTIN_IS_SAME` flag:

```cpp
  template<typename _Tp, typename _Up>
    struct is_same
#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME
    : public integral_constant<bool, __is_same(_Tp, _Up)>
#else
    : public false_type
#endif
    { };

#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME
  template<typename _Tp>
    struct is_same<_Tp, _Tp>
    : public true_type
    { };
#endif
```

Reply via email to