Skip to content

[32-bit] nvfp4_plan_cache.h fails with size_t narrowing on i586 #3181

Description

@VaiTon

Problem

The v0.0.2 source does not compile for i586/32-bit x86 with GCC and -Werror=narrowing. The failure is in src/vt/cuda/nvfp4_plan_cache.h:

constexpr size_t kGolden = sizeof(size_t) == 8 ? size_t{0x9e3779b97f4a7c15ULL}
                                              : size_t{0x9e3779b9UL};

GCC reports:

error: narrowing conversion of ‘11400714819323198485’ from ‘long long unsigned int’ to ‘size_t’ {aka ‘unsigned int’} [-Wnarrowing]

The conditional expression is valid conceptually, but the 64-bit braced initializer is still diagnosed as narrowing when size_t is 32-bit.

Reproducer

Build v0.0.2 on i586 with the normal openSUSE optimization flags and C++20 enabled.

Proposed direction

Use explicit casts or architecture-conditional definitions so both constants are well-formed for 32-bit and 64-bit size_t, for example:

constexpr size_t kGolden = sizeof(size_t) == 8
    ? static_cast<size_t>(0x9e3779b97f4a7c15ULL)
    : static_cast<size_t>(0x9e3779b9UL);

The openSUSE package currently carries this as a downstream patch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions