Open StephanTLavavej opened 2 months ago
I completely agree with your interpretation of the Standard, and believe we should label this "LWG issue needed" instead of "bug". I think it's nonsensical to allow :#c
with the same meaning as :c
, and probably not the intended design.
@vitaut any opinion? I see fmt
allows :#c
(https://godbolt.org/z/GxGKhPh97).
I may be biased by my belief that most format strings are statically determined, which suggests to me we want to tell the user they're being silly rather than silently doing nothing when they add a #
here. (A mechanism to emit arbitrary library warnings during evaluation of constant expressions would be nice. Also a pony.)
I observe a few things:
:#d
is synonymous with :d
(no prefix), so I could see a case for "accept and ignore".c
, so rejection feels correct."000M"
to be formatted?), so rejection also feels correct.I think I'm definitely in favor of "LWG issue needed" and I'd be fine with "libc++ and MSVC's STL were doing the right thing all along".
#
is supposed to be used with numeric presentation types and doesn't make much sense with c
. We could ban it even though it's pretty harmless.
https://godbolt.org/z/vac7s4rKn
With VS 2022 17.12 Preview 1:
https://github.com/microsoft/STL/blob/8af2cc499c94271c8d12baeb45e840f7160e082d/stl/inc/format#L1859-L1861
I believe that all of hash, sign, and zero are affected:
https://github.com/microsoft/STL/blob/8af2cc499c94271c8d12baeb45e840f7160e082d/stl/inc/format#L1971-L1985
Someone should double-check my interpretation of the Standardese here, I'm not an expert.
Related: https://github.com/llvm/llvm-project/issues/106136