public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gpiez at web dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/44500] [C++0x] Bogus narrowing conversion error Date: Sat, 12 Jun 2010 08:46:00 -0000 [thread overview] Message-ID: <20100612084639.9024.qmail@sourceware.org> (raw) In-Reply-To: <bug-44500-11646@http.gcc.gnu.org/bugzilla/> ------- Comment #12 from gpiez at web dot de 2010-06-12 08:46 ------- I am closing this, as it isn't a gcc bug, as it behaves according to the standard. The bug is in the standard, as it mandates f<1,1> // ok f<CHAR_MAX, CHAR_MAX>() // error g<INT_MAX, INT_MAX>() // no error, but undefined behaviuour f(char, char) // error g(int, int) // ok which is inconsistent and surprising. C++0x should really have got rid of the implicit integer promotion. Wasn't the intent of the implicit promotion to be able to write char a,b,c,d; a = b*c/d; and get a correct result even if b*c > CHAR_MAX? I believe nobody does write code like this anymore, and even if, you could simply say "undefined behaviour" ;-) It doesn't work for ints anyway. Instead I have now an implicit integer promotion which forces me to use an explicit cast in compound initializers, where narrowing conversion isn't allowed, while in a simple assignment of course it is allowed (or else a hell would break loose... ). Why not make -Wconversion an error, at least this would be consistent ;-) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44500
next prev parent reply other threads:[~2010-06-12 8:46 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-06-11 10:46 [Bug c++/44500] New: " gpiez at web dot de 2010-06-11 10:57 ` [Bug c++/44500] [C++0x] " manu at gcc dot gnu dot org 2010-06-11 11:34 ` gpiez at web dot de 2010-06-11 11:38 ` redi at gcc dot gnu dot org 2010-06-11 11:43 ` redi at gcc dot gnu dot org 2010-06-11 12:09 ` gpiez at web dot de 2010-06-11 12:51 ` redi at gcc dot gnu dot org 2010-06-11 13:07 ` manu at gcc dot gnu dot org 2010-06-11 13:20 ` redi at gcc dot gnu dot org 2010-06-11 13:27 ` gpiez at web dot de 2010-06-11 13:33 ` manu at gcc dot gnu dot org 2010-06-11 14:56 ` redi at gcc dot gnu dot org 2010-06-12 8:46 ` gpiez at web dot de [this message] 2010-06-12 8:47 ` gpiez at web dot de 2010-06-13 17:14 ` redi at gcc dot gnu dot org 2010-07-09 21:29 ` jason at gcc dot gnu dot org 2010-07-09 21:29 ` jason at gcc dot gnu dot org 2010-07-09 21:30 ` jason at gcc dot gnu dot org [not found] <bug-44500-4@http.gcc.gnu.org/bugzilla/> 2011-03-24 9:32 ` jason at gcc dot gnu.org 2011-03-24 9:37 ` jason at gcc dot gnu.org 2011-03-24 12:04 ` gpiez at web dot de
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=20100612084639.9024.qmail@sourceware.org \ --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).