public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/110854] New: constructor of std::counting_semaphore is not constexpr
@ 2023-07-31 1:58 cooky.ykooc922 at gmail dot com
2023-07-31 2:06 ` [Bug libstdc++/110854] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: cooky.ykooc922 at gmail dot com @ 2023-07-31 1:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110854
Bug ID: 110854
Summary: constructor of std::counting_semaphore is not
constexpr
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: cooky.ykooc922 at gmail dot com
Target Milestone: ---
from [thread.sema#lib:counting_semaphore,constructor]:
constexpr explicit counting_semaphore(ptrdiff_t desired);
but this snippet of code won't compile for gcc >= 11.1 with -std=c++20
=========================================
#include <semaphore>
constinit std::binary_semaphore sem {0};
int main() {}
=========================================
with the following error:
<source>:3:33: error: 'constinit' variable 'sem' does not have a constant
initializer
3 | constinit std::binary_semaphore sem {0};
| ^~~
<source>:3:39: error: call to non-'constexpr' function
'std::counting_semaphore<__least_max_value>::counting_semaphore(std::ptrdiff_t)
[with long int __least_max_value = 1; std::ptrdiff_t = long int]'
3 | constinit std::binary_semaphore sem {0};
| ^
In file included from <source>:1:
/opt/compiler-explorer/gcc-trunk-20230730/include/c++/14.0.0/semaphore:55:16:
note:
'std::counting_semaphore<__least_max_value>::counting_semaphore(std::ptrdiff_t)
[with long int __least_max_value = 1; std::ptrdiff_t = long int]' declared here
55 | explicit counting_semaphore(ptrdiff_t __desired) noexcept
| ^~~~~~~~~~~~~~~~~~
Compiler returned: 1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/110854] constructor of std::counting_semaphore is not constexpr
2023-07-31 1:58 [Bug libstdc++/110854] New: constructor of std::counting_semaphore is not constexpr cooky.ykooc922 at gmail dot com
@ 2023-07-31 2:06 ` pinskia at gcc dot gnu.org
2023-08-04 2:40 ` de34 at live dot cn
2023-10-17 4:23 ` de34 at live dot cn
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-31 2:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110854
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-07-31
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. It looks like it was missed when it was added.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/110854] constructor of std::counting_semaphore is not constexpr
2023-07-31 1:58 [Bug libstdc++/110854] New: constructor of std::counting_semaphore is not constexpr cooky.ykooc922 at gmail dot com
2023-07-31 2:06 ` [Bug libstdc++/110854] " pinskia at gcc dot gnu.org
@ 2023-08-04 2:40 ` de34 at live dot cn
2023-10-17 4:23 ` de34 at live dot cn
2 siblings, 0 replies; 4+ messages in thread
From: de34 at live dot cn @ 2023-08-04 2:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110854
Jiang An <de34 at live dot cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |de34 at live dot cn
--- Comment #2 from Jiang An <de34 at live dot cn> ---
The constructor of the internal __platform_semaphore class currently calls
sem_init, which make it incompatible with constexpr...
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/110854] constructor of std::counting_semaphore is not constexpr
2023-07-31 1:58 [Bug libstdc++/110854] New: constructor of std::counting_semaphore is not constexpr cooky.ykooc922 at gmail dot com
2023-07-31 2:06 ` [Bug libstdc++/110854] " pinskia at gcc dot gnu.org
2023-08-04 2:40 ` de34 at live dot cn
@ 2023-10-17 4:23 ` de34 at live dot cn
2 siblings, 0 replies; 4+ messages in thread
From: de34 at live dot cn @ 2023-10-17 4:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110854
--- Comment #3 from Jiang An <de34 at live dot cn> ---
(In reply to Jiang An from comment #2)
> The constructor of the internal __platform_semaphore class currently calls
> sem_init, which make it incompatible with constexpr...
It seems doable to make the ctor constexpr, but we need to use different
strategies for different C libs.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-17 4:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31 1:58 [Bug libstdc++/110854] New: constructor of std::counting_semaphore is not constexpr cooky.ykooc922 at gmail dot com
2023-07-31 2:06 ` [Bug libstdc++/110854] " pinskia at gcc dot gnu.org
2023-08-04 2:40 ` de34 at live dot cn
2023-10-17 4:23 ` de34 at live dot cn
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).