Skip to content

[Bug]: Build fails with Qt 6.9 due to stricter type checks in QString::arg #4576

@rayslava

Description

@rayslava

Description

While building with Qt 6.9.1 the following error happens:

core/format.cpp:261:19:   required from here
  261 |                                 ret += fmt_int(static_cast<char>(va_arg(ap, int)), flags, field_width, precision, base);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
core/format.cpp:72:56: error: no matching function for call to ‘QString::arg(char&, int&, int&, QChar&)’
   72 |                 QString res = QStringLiteral("%L1").arg(i, precision, base, fillChar);
      |                                                        ^

The function is called from the ret += fmt_int(static_cast<char>(va_arg(ap, int)), flags, field_width, precision, base); but this overload of the QString::arg now is

template <typename T, QString::if_integral_non_char<T> = true>
QString QString::arg(T a, int fieldWidth = 0, int base = 10, QChar fillChar = u' ') const

so the overload of the fmt_int can't be resolved.

Didn't dig deep enough into the formatter logic so not sure about the correct fix but static_cast<short>(static_cast<char>(va_arg(ap, int))) fixed the issue for me.

Subsurface Version

6.0.5424

Platform(s)

Linux

Platform Version

Gentoo

Divecomputer Model

No response

Steps to Reproduce

Attempt to build the code with Qt >= 6.9

Logs

Mentions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions