Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-108136

QAnyStringView constraints are broken and cannot work

    XMLWordPrintable

Details

    • 8a11f16dc0 (qt/qtbase/dev) 8a11f16dc0 (qt/tqtc-qtbase/dev)

    Description

      An attempt to compile Qt with GCC 13 fails, and the compiler complains about

      template <typename Container, if_convertible_to<QString, Container> = true>
       constexpr QAnyStringView(Container &&c, QtPrivate::wrapped_t<Container, QString> &&capacity = {})
      

      saying, this:

       /usr/local/include/c++/13.0.0/type_traits:1417:30: error: invalid use of incomplete type ‘class QString’
       1417 | : public __bool_constant<__is_convertible(_From, _To)>
      

      The compiler is correct. qstring.h includes qanystringview.h, and there we then have a constraint that's querying for convertibility from Container to QString. That cannot work, because it goes down to is_convertible, which in turn requires complete types. And of course it requires complete types, convertibility depends on constructors and conversion operators. QString isn't complete at this point, we haven't defined it yet, we just came here via an include that occurs before the definition of QString.

      In GCC 13, is_convertible uses __is_convertible, which is able to diagnose incomplete types.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mmutz Marc Mutz
            villevoutilainen_qt Ville Voutilainen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes