Skip to content

clang, exception raised or not depending on compiler options #3247

Description

@m5k8

Isolated problem - test.cc:

    #include <fmt/format.h>
    #include <iostream>

    int main()
    {
        char buf[100];
        char* iterator = buf;
        auto ret = fmt::format_to_n(iterator, sizeof(buf), "Test {}", "OK");
	std::cout << ret.size << std::endl;
    
        return 0;
    }

clang version 14.0.6. Then running compiled executable:
clang++ -I fmt/include -std=c++20 test.cc fmt/src/format.cc - OK
clang++ -I fmt/include -std=c++20 -fomit-frame-pointer test.cc fmt/src/format.cc - OK
clang++ -I fmt/include -std=c++2b test.cc fmt/src/format.cc - OK
clang++ -I fmt/include -std=c++2b -fomit-frame-pointer test.cc fmt/src/format.cc - runtime exception:

terminate called after throwing an instance of 'fmt::v9::format_error'
  what():  argument not found

clang++ -I fmt/include -std=c++2b -fomit-frame-pointer -O2 test.cc fmt/src/format.cc - OK again.

So the outcome depends on selected C++ standard and compiler options. c++2b and option for omitting frame pointer fails, but adding optimization O2 to this makes it work again.
I'm not competent enough to dig into this problem, not sure whether it's fmt library issue or compiler issue.
gcc is fine with all these variants. MSVC also (albeit options do not apply).

Please advise.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions