public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/113320] New: libstdc++ accepts std::format(std::move(runtime_fmt), 42);
@ 2024-01-11  1:19 hewillk at gmail dot com
  2024-01-11 10:38 ` [Bug libstdc++/113320] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hewillk at gmail dot com @ 2024-01-11  1:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113320
           Summary: libstdc++ accepts std::format(std::move(runtime_fmt),
                    42);
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

The new constructor of libstdc++'s basic_format_string accepts an rvalue
reference to a runtime-format-string instead of a value, which makes the
following incorrectly accepted:

  #include <format>

  int main() {
    auto runtime_fmt = std::runtime_format("{}");
    auto str = std::format(std::move(runtime_fmt), 42); // should error
  }

https://godbolt.org/z/zjW7shba1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/113320] libstdc++ accepts std::format(std::move(runtime_fmt), 42);
  2024-01-11  1:19 [Bug libstdc++/113320] New: libstdc++ accepts std::format(std::move(runtime_fmt), 42); hewillk at gmail dot com
@ 2024-01-11 10:38 ` redi at gcc dot gnu.org
  2024-01-11 22:50 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-11 10:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2024-01-11
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I implemented the R0 paper, not the final spec. I already have a patch to fix
this.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/113320] libstdc++ accepts std::format(std::move(runtime_fmt), 42);
  2024-01-11  1:19 [Bug libstdc++/113320] New: libstdc++ accepts std::format(std::move(runtime_fmt), 42); hewillk at gmail dot com
  2024-01-11 10:38 ` [Bug libstdc++/113320] " redi at gcc dot gnu.org
@ 2024-01-11 22:50 ` redi at gcc dot gnu.org
  2024-01-12  9:49 ` cvs-commit at gcc dot gnu.org
  2024-01-12 20:38 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-11 22:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642741.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/113320] libstdc++ accepts std::format(std::move(runtime_fmt), 42);
  2024-01-11  1:19 [Bug libstdc++/113320] New: libstdc++ accepts std::format(std::move(runtime_fmt), 42); hewillk at gmail dot com
  2024-01-11 10:38 ` [Bug libstdc++/113320] " redi at gcc dot gnu.org
  2024-01-11 22:50 ` redi at gcc dot gnu.org
@ 2024-01-12  9:49 ` cvs-commit at gcc dot gnu.org
  2024-01-12 20:38 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-12  9:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:5fbc1b2e7c1bdf11f64765b278f477310c0f3436

commit r14-7174-g5fbc1b2e7c1bdf11f64765b278f477310c0f3436
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jan 10 20:54:11 2024 +0000

    libstdc++: Fix std::runtime_format deviations from the spec [PR113320]

    I seem to have implemented this feature based on the P2918R0 revision,
    not the final P2918R2 one that was approved for C++26. This commit fixes
    it.

    The runtime-format-string type should not have a publicly accessible
    data member, so add a constructor and make it a friend of
    basic_format_string. It should also be non-copyable, so that it can only
    be constructed from a prvalue via temporary materialization. Change the
    basic_format_string constructor parameter to pass by value. Also add
    noexcept to the constructors and runtime_format generator functions.

    libstdc++-v3/ChangeLog:

            PR libstdc++/113320
            * include/std/format (__format::_Runtime_format_string): Add
            constructor and disable copy operations.
            (basic_format_string(_Runtime_format_string)): Add noexcept and
            take parameter by value not rvalue reference.
            (runtime_format): Add noexcept.
            * testsuite/std/format/runtime_format.cc: Check noexcept. Check
            that construction is only possible from prvalues, not xvalues.

    Reviewed-by: Daniel Krügler <daniel.kruegler@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/113320] libstdc++ accepts std::format(std::move(runtime_fmt), 42);
  2024-01-11  1:19 [Bug libstdc++/113320] New: libstdc++ accepts std::format(std::move(runtime_fmt), 42); hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2024-01-12  9:49 ` cvs-commit at gcc dot gnu.org
@ 2024-01-12 20:38 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-12 20:38 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed, thanks for checking it

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-12 20:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11  1:19 [Bug libstdc++/113320] New: libstdc++ accepts std::format(std::move(runtime_fmt), 42); hewillk at gmail dot com
2024-01-11 10:38 ` [Bug libstdc++/113320] " redi at gcc dot gnu.org
2024-01-11 22:50 ` redi at gcc dot gnu.org
2024-01-12  9:49 ` cvs-commit at gcc dot gnu.org
2024-01-12 20:38 ` 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).