public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/103924] New: views::join combined with std::string cannot be used in constant expressions
@ 2022-01-06  1:56 hewillk at gmail dot com
  2022-01-06 13:46 ` [Bug libstdc++/103924] " ppalka at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hewillk at gmail dot com @ 2022-01-06  1:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103924
           Summary: views::join combined with std::string cannot be used
                    in constant expressions
           Product: gcc
           Version: 12.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 following code cannot be used as a constant expression, but it should work
since constexpr non-propagating-cache and std::string have been implemented.

#include <string>
#include <ranges>

int main() {
  using namespace std::string_literals;
  static_assert(std::ranges::distance(
      std::views::single("42"s) | std::views::join));
}

https://godbolt.org/z/zPv4xnxnP

#include <string>
#include <ranges>

int main() {
  using namespace std::string_literals;
  static_assert(std::ranges::distance(
      std::views::iota(0, 1) 
      | std::views::transform([](auto) { return "42"s; })
      | std::views::join));
}

https://godbolt.org/z/d5TM4x53z

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

* [Bug libstdc++/103924] views::join combined with std::string cannot be used in constant expressions
  2022-01-06  1:56 [Bug libstdc++/103924] New: views::join combined with std::string cannot be used in constant expressions hewillk at gmail dot com
@ 2022-01-06 13:46 ` ppalka at gcc dot gnu.org
  2022-10-04 14:41 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-06 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-01-06
             Status|UNCONFIRMED                 |NEW
                 CC|                            |ppalka at gcc dot gnu.org

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

* [Bug libstdc++/103924] views::join combined with std::string cannot be used in constant expressions
  2022-01-06  1:56 [Bug libstdc++/103924] New: views::join combined with std::string cannot be used in constant expressions hewillk at gmail dot com
  2022-01-06 13:46 ` [Bug libstdc++/103924] " ppalka at gcc dot gnu.org
@ 2022-10-04 14:41 ` ppalka at gcc dot gnu.org
  2024-03-29 21:20 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-04 14:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
I encountered a similar problem when testing views::join_with:

#include <string>
#include <ranges>
constexpr std::string_view rs[] = {"42"};
static_assert(!std::ranges::empty(rs |
std::views::join_with(std::string(""))));

error: accessing ‘std::__cxx11::basic_string<char>::<unnamed
union>::_M_allocated_capacity’ member instead of initialized
‘std::__cxx11::basic_string<char>::<unnamed union>::_M_local_buf’ member in
constant expression

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

* [Bug libstdc++/103924] views::join combined with std::string cannot be used in constant expressions
  2022-01-06  1:56 [Bug libstdc++/103924] New: views::join combined with std::string cannot be used in constant expressions hewillk at gmail dot com
  2022-01-06 13:46 ` [Bug libstdc++/103924] " ppalka at gcc dot gnu.org
  2022-10-04 14:41 ` ppalka at gcc dot gnu.org
@ 2024-03-29 21:20 ` ppalka at gcc dot gnu.org
  2024-03-29 21:21 ` ppalka at gcc dot gnu.org
  2024-03-30  1:13 ` hewillk at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-29 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 114530 has been marked as a duplicate of this bug. ***

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

* [Bug libstdc++/103924] views::join combined with std::string cannot be used in constant expressions
  2022-01-06  1:56 [Bug libstdc++/103924] New: views::join combined with std::string cannot be used in constant expressions hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2024-03-29 21:20 ` ppalka at gcc dot gnu.org
@ 2024-03-29 21:21 ` ppalka at gcc dot gnu.org
  2024-03-30  1:13 ` hewillk at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-29 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
From PR114530:

#include <ranges>
#include <vector>

static_assert(
  std::ranges::distance(
      std::views::single(std::views::cartesian_product(std::string{}))
    | std::views::join
  ) == 0
);

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

* [Bug libstdc++/103924] views::join combined with std::string cannot be used in constant expressions
  2022-01-06  1:56 [Bug libstdc++/103924] New: views::join combined with std::string cannot be used in constant expressions hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2024-03-29 21:21 ` ppalka at gcc dot gnu.org
@ 2024-03-30  1:13 ` hewillk at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: hewillk at gmail dot com @ 2024-03-30  1:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Patrick Palka from comment #2)
> *** Bug 114530 has been marked as a duplicate of this bug. ***

That's my lost memory.

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

end of thread, other threads:[~2024-03-30  1:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06  1:56 [Bug libstdc++/103924] New: views::join combined with std::string cannot be used in constant expressions hewillk at gmail dot com
2022-01-06 13:46 ` [Bug libstdc++/103924] " ppalka at gcc dot gnu.org
2022-10-04 14:41 ` ppalka at gcc dot gnu.org
2024-03-29 21:20 ` ppalka at gcc dot gnu.org
2024-03-29 21:21 ` ppalka at gcc dot gnu.org
2024-03-30  1:13 ` hewillk at gmail dot com

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).