public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Reporitng libstdc++ bug without account to Bugzilla
@ 2023-11-20 14:22 Palmu, Miro M
  2023-11-20 14:43 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Palmu, Miro M @ 2023-11-20 14:22 UTC (permalink / raw)
  To: gcc

Hi

I think I found libstdc++ bug and I tried to report to Bugzilla but "user account creation has been restricted".

So I'm going to report it here in hope that someone with a account could report it to Bugzilla if they seem it fit.

Using gcc 13.2 with -std=c++23 code below (https://godbolt.org/z/Kc36rcMYx) does not compile even if all compile time
allocations are freed before returning from compile time context. MSVC is able to compile it.

I was suggested elsewhere that it could be some oversight in the SSO implementation.
 
```
#include <string>
#include <functional>
#include <algorithm>
#include <vector>

using namespace std;
using namespace std::literals;

constexpr auto foo() {
    const auto vec = vector{ "a"s, "b"s, "c"s };
    return ranges::fold_left(vec, ""s, plus{});
}

constexpr auto bar() {
    return foo().size();
}

int main() {
    constexpr auto _ = bar(); // This does not compile
}
```

Error message:

```
<source>: In function 'int main()':
<source>:19:27:   in 'constexpr' expansion of 'bar()'
<source>:15:23:   in 'constexpr' expansion of 'foo()()'
<source>:19:28:   in 'constexpr' expansion of 'std::ranges::__fold_left_fn::operator()(_Range&&, _Tp, _Fp) const [with _Range = const std::vector<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >&; _Tp = std::__cxx11::basic_string<char>; _Fp = std::plus<void>](vec, std::literals::string_literals::operator""s(const char*, std::size_t)(0), (std::plus<void>(), std::plus<void>()))'
<source>:19:28:   in 'constexpr' expansion of 'std::__cxx11::basic_string<char>((* & std::move<__cxx11::basic_string<char>&>(__init)))'
<source>:19:28: 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
   19 |     constexpr auto _ = bar();
      |                            ^
```

Miro Palmu

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

end of thread, other threads:[~2023-11-20 14:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 14:22 Reporitng libstdc++ bug without account to Bugzilla Palmu, Miro M
2023-11-20 14:43 ` Jonathan Wakely

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