public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/110602] New: std::format and friends are accessible without std::
@ 2023-07-09 3:21 tchaikov at gmail dot com
2023-07-09 3:26 ` [Bug libstdc++/110602] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: tchaikov at gmail dot com @ 2023-07-09 3:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110602
Bug ID: 110602
Summary: std::format and friends are accessible without std::
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: tchaikov at gmail dot com
Target Milestone: ---
following code should not compile as "format_to" should be placed in the "std"
namespace:
====8<====
#include <format>
std::string foo() {
std::string ss;
format_to(std::back_inserter(ss), "{}", 1);
return ss;
}
int main() {
return foo().size() != 1;
}
====>8====
but it compiles with gcc trunk (at the time of writing) and gcc 13.1. with
following command line options:
-std=c++23 -O2 -Wall -Wextra
or
-std=c++20 -O2 -Wall -Wextra
i also tested clang + libstdc++ and clang + libc++. all of these combinations
compiles. see https://godbolt.org/z/GhrxPx7Gz for the reproducer.
i was trying to figure out by inspecting the preprocessed source file and
messing around with a sample code below to see if we somehow opened the std
namespace in format or some files included by it but failed:
std::string foo() {
std::string ss;
auto out = std::back_inserter(ss);
// auto args = make_format_args(1, 2, 3);
// basic_format_string<char, int, int> fmt_str{"{} {}"};
auto std_args = std::make_format_args(1, 2, 3);
auto std_wargs = std::make_wformat_args(1, 2, 3);
// does not compile
// auto args = std::make_format_args(1, 2, 3);
// does not compile
// auto wargs = std::make_wformat_args(1, 2, 3);
vformat_to(out, "{} {} {}", std_args);
auto s = vformat("{}", std_args);
format_to(out, "{}", ss);
return ss;
}
it turns out make_format_args and make_wformat_args are still in "std"
namespace, while format, format_to and vformat_to can be accessed with and
without qualified with 'std'
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/110602] std::format and friends are accessible without std::
2023-07-09 3:21 [Bug libstdc++/110602] New: std::format and friends are accessible without std:: tchaikov at gmail dot com
@ 2023-07-09 3:26 ` pinskia at gcc dot gnu.org
2023-07-09 3:27 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-09 3:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110602
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is how agrument depedent namelookup works.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/110602] std::format and friends are accessible without std::
2023-07-09 3:21 [Bug libstdc++/110602] New: std::format and friends are accessible without std:: tchaikov at gmail dot com
2023-07-09 3:26 ` [Bug libstdc++/110602] " pinskia at gcc dot gnu.org
@ 2023-07-09 3:27 ` pinskia at gcc dot gnu.org
2023-07-09 3:40 ` tchaikov at gmail dot com
2023-07-09 9:36 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-09 3:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110602
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
See https://en.cppreference.com/w/cpp/language/adl for a quick reference on the
subject.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/110602] std::format and friends are accessible without std::
2023-07-09 3:21 [Bug libstdc++/110602] New: std::format and friends are accessible without std:: tchaikov at gmail dot com
2023-07-09 3:26 ` [Bug libstdc++/110602] " pinskia at gcc dot gnu.org
2023-07-09 3:27 ` pinskia at gcc dot gnu.org
@ 2023-07-09 3:40 ` tchaikov at gmail dot com
2023-07-09 9:36 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: tchaikov at gmail dot com @ 2023-07-09 3:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110602
--- Comment #3 from kefu chai <tchaikov at gmail dot com> ---
hi Andrew,
ahh, i missed that. thank you for pointing this out.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/110602] std::format and friends are accessible without std::
2023-07-09 3:21 [Bug libstdc++/110602] New: std::format and friends are accessible without std:: tchaikov at gmail dot com
` (2 preceding siblings ...)
2023-07-09 3:40 ` tchaikov at gmail dot com
@ 2023-07-09 9:36 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-09 9:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110602
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to kefu chai from comment #0)
> i also tested clang + libstdc++ and clang + libc++. all of these
> combinations compiles.
That's usually a sign the code is valid.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-09 9:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-09 3:21 [Bug libstdc++/110602] New: std::format and friends are accessible without std:: tchaikov at gmail dot com
2023-07-09 3:26 ` [Bug libstdc++/110602] " pinskia at gcc dot gnu.org
2023-07-09 3:27 ` pinskia at gcc dot gnu.org
2023-07-09 3:40 ` tchaikov at gmail dot com
2023-07-09 9:36 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).