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

            Bug ID: 118676
           Summary: Getting "the ABI of passing union with ‘long double’
                    has changed in GCC 4.4" warning for a function that
                    doesn't take long double and isn't subject to ABI at
                    all (static)
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nabijaczleweli at nabijaczleweli dot xyz
  Target Milestone: ---

When compiling:

cmd/numfmt.cpp: In function ‘std::optional<std::variant<long int, long double>
> {anonymous}::parse_from(const char*, std::string_view, from_to_t, int&, bool,
const char*)’:
cmd/numfmt.cpp:54:128: note: the ABI of passing union with ‘long double’ has
changed in GCC 4.4
   54 |                                                                        
  bool log_error = true, const char * whatfor = nullptr) {
      |                                                                        
                                                       ^

then when linking:

lto1: note: the ABI of passing union with ‘long double’ has changed in GCC 4.4

The astute reader will notice that "std::optional<std::variant<long int, long
double> > {anonymous}::parse_from(const char*, std::string_view, from_to_t,
int&, bool, const char*)" doesn't get a long double passed.

And the arrow points at nothing.

Also, the function isn't subject to an ABI at all since it's static-linkage (in
anonymous namespace, but same happens with an explicit static).

Also, I get you want to catch the long tail here, but GCC 4.4 was 2009 which
was like 16 years ago? Maybe the solution to this is to drop the warning
entirely.

Repro on debian GCC 4:12.2.0-3 (libstdc++-12-dev:amd64 12.2.0-14) and
4:13.2.0-7 (libstdc++-13-dev:x32 13.2.0-18).


Trimmed-down original:
#include <cstdint>
#include <optional>
#include <string_view>
#include <variant>
namespace {
        enum from_to_t {};
        std::optional<std::variant<std::int64_t, long double>> parse_from(const
char *, std::string_view, from_to_t, int &, bool = true, const char * =
nullptr) {
                return {};
        }
}

Reduced:
#include <variant>
namespace {
        std::variant<int, long double> parse_from() {
                return {};
        }
}

Reduced:
#include <variant>
static std::variant<int, long double> parse_from() {
        return {};
}

Reply via email to