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

            Bug ID: 119246
           Summary: Result basic_format_arg::check_dynamic_spec is
                    incorrect for extended floating point types
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tkaminsk at gcc dot gnu.org
  Target Milestone: ---

Currently for parse_con `ctx.check_dynamic_spec<float>(n)` returns true, 
if the argument at the position n have std::bfloat16_t, std::float16_t
(_Float16), std::float32_t (_Float32). 
Similary `ctx.check_dynamic_spec<double>(n)` returns true for the
std::float64_t (_Float64).

Code example (https://godbolt.org/z/Enc5WzaKn):
```
#include <format>

template<unsigned pos, class Type>
struct Tester {};

template<unsigned pos, class Type>
struct std::formatter<Tester<pos, Type>, char> {
  constexpr format_parse_context::iterator parse(format_parse_context& ctx)
const {
    ctx.check_dynamic_spec<Type>(pos);
    return ctx.begin();
  }

  template<typename Out>
  Out format(Tester<pos, Type>, basic_format_context<Out, char>& ctx) const {
    return ctx.out();
  }
};

static_assert(std::formattable<Tester<1, float>, char>);

int main() {
    (void)std::format("{}{}", Tester<1, float>{}, _Float16{});
    (void)std::format("{}{}", Tester<1, double>{}, _Float64{});
    //std::format("{}{}", Tester<1, int>{}, _Float16{});
}


```

Reply via email to