public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96115] New: Char literal, decays to a pointer when passed to function pointer
@ 2020-07-08 14:21 boris_oncev at hotmail dot com
  2020-07-08 15:45 ` [Bug c++/96115] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: boris_oncev at hotmail dot com @ 2020-07-08 14:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96115

            Bug ID: 96115
           Summary: Char literal, decays to a pointer when passed to
                    function pointer
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boris_oncev at hotmail dot com
  Target Milestone: ---

Example code:
struct SL{
    template <int N>
    SL(const char (&Str)[N]) {}
};

int foo(SL x) {
    return 2;
}

int main() {
    int (*f)(SL) = &foo;
    foo("asd"); // works fine
    f("asd"); // error could not convert '(const char*) to SL
}

Godbot link:
https://godbolt.org/z/vo8lOf

works on other compilers clang, msvc and icc

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

end of thread, other threads:[~2021-12-17  6:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 14:21 [Bug c++/96115] New: Char literal, decays to a pointer when passed to function pointer boris_oncev at hotmail dot com
2020-07-08 15:45 ` [Bug c++/96115] " redi at gcc dot gnu.org
2020-11-03 15:47 ` ldalessandro at gmail dot com
2021-12-17  6:09 ` [Bug c++/96115] string " 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).