Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2010975

Summary: Missing C++2a std::string starts_with(); method on libstdc++
Product: Red Hat Enterprise Linux 8 Reporter: Vinícius Ferrão <vinicius>
Component: gccAssignee: Marek Polacek <mpolacek>
gcc sub component: system-version QA Contact: qe-baseos-tools-bugs
Status: CLOSED WONTFIX Docs Contact:
Severity: unspecified    
Priority: unspecified CC: ahajkova, fweimer, jakub, ohudlick
Version: 8.4Flags: pm-rhel: mirror+
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-10-05 17:56:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vinícius Ferrão 2021-10-05 17:17:02 UTC
Description of problem:
It seems that starts_with(); method from std::string is missing on EL8.4 even when we use --std=c++2a with gcc (or clang). Both compilers supports C++20 but it seems the implementation is missing from libstdc++.

[root@localhost ~]# g++ --std=c++2a starts_with.c 
starts_with.c: In function 'int main()':
starts_with.c:6:19: error: 'std::__cxx11::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'starts_with'
  std::cout << var.starts_with("is") << std::endl;
                   ^~~~~~~~~~~

Version-Release number of selected component (if applicable):
gcc-c++-8.4.1-1.el8.x86_64
clang-devel-11.0.0-1.module+el8.4.0+8598+a071fcd5.x86_64
libstdc++-8.4.1-1.el8.x86_64
libgcc-8.4.1-1.el8.x86_64
clang-tools-extra-11.0.0-1.module+el8.4.0+8598+a071fcd5.x86_64
clang-11.0.0-1.module+el8.4.0+8598+a071fcd5.x86_64
gcc-8.4.1-1.el8.x86_64
clang-libs-11.0.0-1.module+el8.4.0+8598+a071fcd5.x86_64
libstdc++-devel-8.4.1-1.el8.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Create an example program with std::string and use the method starts_with();
2. Fail to compile with bundled gcc and libstdc++

Actual results:
Compiler error during compile phase.

Expected results:
Successful compilation.

Additional info:
std::string starts_with() is defined on C++20: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0457r2.html

It should be supported if we have the option to enable --std=c++2a on compilers.

Example code:
#include <string>
#include <iostream>

int main() {
	std::string var = "this is a test";
	std::cout << var.starts_with("is") << std::endl;

	return 0;
}

Comment 1 Marek Polacek 2021-10-05 17:56:34 UTC
C++20 support in GCC 8 is so early and experimental that I'm not minded to backport any new features there, sorry.

starts_with was added in GCC 9.  On RHEL 8 you can use the GCC Toolset to get a newer compiler than the system one:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/developing_c_and_cpp_applications_in_rhel_8/gcc-toolset-10_toolsets
which has better C++20 support.

Comment 2 Vinícius Ferrão 2021-10-05 18:04:54 UTC
No problem Marek. I understood, incorrectly, that since gcc allowed --std=c++2a it would support it. I'll default back to --std=c++17.

Thank you.

Comment 3 Marek Polacek 2021-10-13 15:41:34 UTC
Further clarification: C++20 in GCC 10 is still experimental, even though the string::starts_with member is present.