Skip to content

Compilation error since 11.1.0 with NVIDIA's nvcc compiler #4297

@breyerml

Description

@breyerml

Using the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.15)

project(MyProject)

enable_language(CUDA)

add_executable(prog main.cu)

include(FetchContent)
FetchContent_Declare(fmt
                 GIT_REPOSITORY https://github.com/fmtlib/fmt.git
                 GIT_TAG 11.1.0
                 QUIET
)
FetchContent_MakeAvailable(fmt)

target_link_libraries(prog PUBLIC fmt::fmt)

with the main.cu file

#include "fmt/format.h"
#include "fmt/chrono.h"

#include <chrono>
#include <iostream>

int main() {
  std::cout << fmt::format("{}", std::chrono::milliseconds{ 10 }) << std::endl;
  return 0;
}

built via cmake .. && make together with nvcc version cuda_12.2.r12.2/compiler.33191640_0 results in the following compiler error:

/Documents/test/fmt/build/_deps/fmt-src/include/fmt/chrono.h(2310): error: too many arguments in function call
          detail::utc_clock::to_sys(val), ctx);
                                    ^

/Documents/test/fmt/build/_deps/fmt-src/include/fmt/chrono.h(2310): error: the object has type qualifiers that are not compatible with the member function "fmt::v11::detail::utc_clock::to_sys"
            object type is: const fmt::v11::detail::utc_clock
          detail::utc_clock::to_sys(val), ctx);
          ^

This error happens with versions 11.1.0,11.1.1, and master.
A git bisect revealed that the offending commit is: 89af1ad

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions