public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51630] failure to detect missing Date: Wed, 21 Dec 2011 16:15:00 -0000 [thread overview] Message-ID: <bug-51630-4-UKw3vMbyrV@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-51630-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51630 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|CLOSED |RESOLVED Resolution|WONTFIX |INVALID --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-21 16:08:15 UTC --- (Setting status back to RESOLVED+INVALID, we don't use CLOSED in GCC's bugzilla, and WONTFIX is not appropriate because no G++ dev has agreed there is a bug here and said it won't be fixed.) (In reply to comment #0) > > template<typename T> > const T & max(const T & x, const T & y){ > return (x < y) ? y : x; > } This template has valid syntax. It follows the rules of the C++ grammar. Whether it can be compiled depends on the template arguments. > struct name {}; > > void test3(){ > name x, y, z; > z = max(x, y); // error name doesn't have < operator That function call also has valid syntax. It follows the rules of the C++ grammar. > This looks like a bug to me. For what it's worth, this second example fails to > compile with MSVC 9.0 pointing to an error for lack of operator < as one would > expect. It fails to *compile* with G++ too, but using -fsyntax-only doesn't do compilation. (In reply to comment #7) > what I expected was that -fsyntax-only would run the normal process but skip > the code generation. I don't think that's an unreasonable expectation from the > name of the option and the simple description of it. > > Also I wouldn't characterize the program as not having any syntax errors. The > first example > > name test2(){ > name x, y; > return (x < y) ? y : x; > } > > generates an compile time error as one would expect. If the same code were > placed inside a macro, it would also provoke an error. Then you move it into > at template - and voila - no syntax error. Templates are not just fancy macros, you know C++ well enough to know that. > This is not regular or intuitive > behavior. When you tested it you also expected to see an error - to the extent > you tried on several versions of gcc. When I tested it I *did* see an error. I tested several versions because I was trying to reproduce your reported lack of an error, because I missed you were using -fsyntax-only > If your asking me what I want, I would respond that the current behavior of the > -fsyntax-only is inconsistent and confusing and has room for improvement. It's > not much of an answer to say "don't do that". Taken to it's logical > conclusion, you might just skip emission of compile time errors all together > and replace them with the admonition - don't write incorrect code ! That's not the logical conclusion, it's a strawman. If a user complains that omitting the -g flag causes there to be no debug symbols in their objects, they've apparently misunderstood the purpose of the option and "don't do that" is a reasonable answer.
next prev parent reply other threads:[~2011-12-21 16:09 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-12-20 7:35 [Bug c++/51630] New: " ramey at rrsd dot com 2011-12-20 7:40 ` [Bug c++/51630] " ramey at rrsd dot com 2011-12-20 8:59 ` redi at gcc dot gnu.org 2011-12-20 9:10 ` redi at gcc dot gnu.org 2011-12-20 10:31 ` paolo.carlini at oracle dot com 2011-12-20 21:22 ` ramey at rrsd dot com 2011-12-21 5:40 ` redi at gcc dot gnu.org 2011-12-21 7:22 ` ramey at rrsd dot com 2011-12-21 16:15 ` redi at gcc dot gnu.org [this message] 2011-12-21 16:20 ` redi 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-51630-4-UKw3vMbyrV@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).