public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "haoxintu at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96103] New: Unclear diagnostic for a function return with "decltype(auto)" Date: Tue, 07 Jul 2020 17:41:19 +0000 [thread overview] Message-ID: <bug-96103-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96103 Bug ID: 96103 Summary: Unclear diagnostic for a function return with "decltype(auto)" Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- Hi, all. This code, "decltype(auto)" in return type is a c++14 extension and I guess GCC might diagnose this better. $cat test.cc decltype(auto) foo () {} $g++ -c -std=c++11 test.cc test.cc:1:10: error: expected primary-expression before ‘auto’ 1 | decltype(auto) foo () {} | ^~~~ test.cc: In function ‘int foo()’: test.cc:1:24: warning: no return statement in function returning non-void [-Wreturn-type] 1 | decltype(auto) foo () {} | ^ $g++ -c -std=c++14 test.cc //emits nothing While in Clang: $clang++ -c -std=c++11 test.cc test.cc:1:10: warning: 'decltype(auto)' type specifier is a C++14 extension [-Wc++14-extensions] decltype(auto) foo () {} ^ test.cc:1:1: error: deduced return types are a C++14 extension decltype(auto) foo () {} ^ 1 warning and 1 error generated. I guess users can not fix the code according to the errors emitted until they realized this is a C++14 extension. Should GCC recognizes the C++14 extension first when parsing this code and then emits the appropriate diagnostic information? Thanks, Haoxin
next reply other threads:[~2020-07-07 17:41 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-07 17:41 haoxintu at gmail dot com [this message] 2020-07-07 20:19 ` [Bug c++/96103] " mpolacek at gcc dot gnu.org 2020-07-07 21:13 ` mpolacek at gcc dot gnu.org 2020-07-08 13:33 ` cvs-commit at gcc dot gnu.org 2020-07-08 13:34 ` mpolacek at gcc dot gnu.org 2021-09-07 17:07 ` pinskia at gcc dot gnu.org 2021-09-07 17:07 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-96103-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).