public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95596] New: string literal wrong overload resolution (char* vs std::string)
@ 2020-06-09  3:05 bzsurr at protonmail dot com
  2020-06-09  7:17 ` [Bug c++/95596] " bzsurr at protonmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bzsurr at protonmail dot com @ 2020-06-09  3:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

end of thread, other threads:[~2023-05-27 17:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09  3:05 [Bug c++/95596] New: string literal wrong overload resolution (char* vs std::string) bzsurr at protonmail dot com
2020-06-09  7:17 ` [Bug c++/95596] " bzsurr at protonmail dot com
2020-06-09 13:43 ` redi at gcc dot gnu.org
2020-06-09 13:45 ` redi at gcc dot gnu.org
2020-06-10 19:30 ` mpolacek at gcc dot gnu.org
2020-07-22 14:05 ` redi at gcc dot gnu.org
2020-07-22 14:06 ` redi at gcc dot gnu.org
2022-02-14 20:11 ` pinskia at gcc dot gnu.org
2023-05-27 17:58 ` pinskia at gcc dot gnu.org

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