Issue 179118
Summary After #136203, compile errors in qt5-webengine
Labels clang
Assignees cor3ntin, zyn0217
Reporter DimitryAndric
    After the commits for #136203 "[Clang] Bypass TAD during overload resolution if a perfect match exists" (377ec36b323ea99ca316cb5cf79c0a0c93eebc37 and its reapplication 8c5a307bd8d406e6167a5cd3ce3c74e2e3bfb2a6), I am getting errors when building the www/qt5-webengine port on FreeBSD. This is the project in https://github.com/qt/qtwebengine/tree/v5.15.19-lts, which uses a somewhat older version of chromium that has its own `std::optional` implementation, similar to what is done in abseil: https://github.com/qt/qtwebengine-chromium/tree/6d29e9cfcfffa7632cc3858ceaf8940677ba9c91, in particular https://github.com/qt/qtwebengine-chromium/blob/6d29e9cfcfffa7632cc3858ceaf8940677ba9c91/chromium/base/optional.h.

```
In file included from ./../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.cc:5:
In file included from ../../../../kde-qtwebengine-5g.15.19p0/src/3rdparty/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h:9:
In file included from ../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/third_party/blink/renderer/core/layout/layout_block.h:29:
In file included from ../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/third_party/blink/renderer/core/layout/layout_box.h:30:
In file included from ../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/third_party/blink/renderer/core/frame/local_frame.h:35:
In file included from ../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/base/time/default_tick_clock.h:9:
In file included from ../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/base/time/tick_clock.h:9:
In file included from ../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/base/time/time.h:61:
In file included from ../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/base/check_op.h:12:
../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/base/template_util.h:210:48: error: no member named 'value' in 'std::is_constructible<blink::LayoutUnit, base::Optional<blink::LayoutUnit> &>'
  210 |     : std::conditional_t<static_cast<bool>(B1::value), B1, disjunction<Bn...>> {
 | ~~~~^
../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/base/optional.h:487:39: note: in instantiation of template class 'base::disjunction<std::is_constructible<blink::LayoutUnit, base::Optional<blink::LayoutUnit> &>, std::is_constructible<blink::LayoutUnit, const base::Optional<blink::LayoutUnit> &>, std::is_constructible<blink::LayoutUnit, base::Optional<blink::LayoutUnit> &&>, std::is_constructible<blink::LayoutUnit, const base::Optional<blink::LayoutUnit> &&>, std::is_convertible<base::Optional<blink::LayoutUnit> &, blink::LayoutUnit>, std::is_convertible<const base::Optional<blink::LayoutUnit> &, blink::LayoutUnit>, std::is_convertible<base::Optional<blink::LayoutUnit> &&, blink::LayoutUnit>, std::is_convertible<const base::Optional<blink::LayoutUnit> &&, blink::LayoutUnit>>' requested here
 487 |                            !internal::IsConvertibleFromOptional<T, U>::value &&
      | ^
../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/base/optional.h:490:3: note: while substituting prior template arguments into non-type template parameter [with U = blink::LayoutUnit]
  490 |   Optional(const Optional<U>& other) : internal::OptionalBase<T>(other) {}
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/__type_traits/is_constructible.h:23:102: note: while substituting deduced template arguments into function template 'Optional' [with U = blink::LayoutUnit, $1 = (no value)]
   23 | struct _LIBCPP_NO_SPECIALIZATIONS is_constructible : integral_constant<bool, __is_constructible(_Tp, _Args...)> {};
      | ^
../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/base/optional.h:576:16: note: in instantiation of template class 'std::is_constructible<blink::LayoutUnit, base::Optional<blink::LayoutUnit> &>' requested here
  576 |           std::is_constructible<T, U>::value &&
 | ^
./../../../../kde-qtwebengine-5.15.19p0/src/3rdparty/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_types.cc:82:17: note: while substituting deduced template arguments into function template 'operator=' [with U = base::Optional<LayoutUnit> &]
   82 |     inline_size = default_inline_size;
      |                 ^

````

What seems to happen here is that SFINAE 'fails' and the type for `std::is_constructible` cannot be formed, therefore its `::value` member is not available, but clang still produces an error instead of silently ignoring the inconstructible type.

I have attempted to reduce the code to a smaller test case, which compiles fine with clang 19 and 20, but fails after 8c5a307bd8d406e6167a5cd3ce3c74e2e3bfb2a6):

```c++
namespace std {
inline namespace {
template <bool, class _IfRes, class> using conditional_t = _IfRes;
template <int __v> struct integral_constant {
  static const int value = __v;
};
template <bool> struct enable_if;
template <bool _Bp> using enable_if_t = typename enable_if<_Bp>::type;
template <class, class> struct is_convertible;
template <class _Tp, class... _Args>
struct is_constructible : integral_constant<__is_constructible(_Tp, _Args...)> {
};
} // namespace
} // namespace std
namespace base {
template <typename...> struct disjunction;
template <typename B1, typename... Bn>
struct disjunction<B1, Bn...>
    : std::conditional_t<B1::value, B1, disjunction<>> {};
template <typename> class Optional;
template <typename T, typename U>
using IsConvertibleFromOptional =
 disjunction<std::is_constructible<T, Optional<U> &>,
 std::is_constructible<T, const Optional<U> &>,
 std::is_constructible<T, Optional<U> &&>,
 std::is_constructible<T, const Optional<U> &&>,
 std::is_convertible<Optional<U> &, T>,
 std::is_convertible<const Optional<U> &, T>,
 std::is_convertible<Optional<U> &&, T>,
 std::is_convertible<const Optional<U> &&, T>>;
template <typename T> class Optional {
public:
  Optional(Optional &&);
  template <typename U, std::enable_if_t<
                            IsConvertibleFromOptional<T, U>::valuebool> = false>
  Optional(Optional<U>);
  void operator=(const Optional &);
  template <typename U>
 std::enable_if_t<std::is_constructible<T, U>::value> operator=(U &&);
};
} // namespace base
struct LayoutUnit {
 LayoutUnit(base::Optional<LayoutUnit>);
};
struct foo_t {
 base::Optional<LayoutUnit> opt_layout_unit_;
  base::Optional<LayoutUnit> baz_opt_layout_unit;
  void baz() { opt_layout_unit_ = baz_opt_layout_unit; }
};
```

Obviously, if somebody knows a workaround to make clang 21 build qt5-webengine, that would also be nice. I suspect Chromium's older custom Optional implementation is not completely up to par, which  is probably why they replaced it with Abseil's implementation later on.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to