[Bug c++/95596] New: string literal wrong overload resolution (char* vs std::string)
bzsurr at protonmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jun 9 03:05:23 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95596
Bug ID: 95596
Summary: string literal wrong overload resolution (char* vs
std::string)
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: bzsurr at protonmail dot com
Target Milestone: ---
Looking at the following code gcc calls the _char*_ overload, according to the
standard the string literal is of type const array of char, so the non const
char pointer should not be part of the overload set.
#include <cstdio>
#include <string>
void foo(char*) { puts("char*"); }
void foo(std::string) { puts("std::string"); }
int main()
{
foo("Hello World");
}
Compiler Explorer Link:
https://godbolt.org/z/82D4LT
More information about the Gcc-bugs
mailing list