public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used
@ 2012-01-04 18:54 james.kanze at gmail dot com
  2012-01-04 19:03 ` [Bug c++/51755] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: james.kanze at gmail dot com @ 2012-01-04 18:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51755

             Bug #: 51755
           Summary: -Wconversion generates false warnings when the ternary
                    operator is used
    Classification: Unclassified
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: james.kanze@gmail.com


This might be covered by 40752; it's related.  But if -Wconversion is used,
simple code like the following

    int main()
    {
        static uint8_t const k = 0x02;
        bool c = true;
        uint8_t x = 0;
        x |= c ? k : 0;
    }

triggers a warning, although there is absolutely no possibility of overflow.


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

* [Bug c++/51755] -Wconversion generates false warnings when the ternary operator is used
  2012-01-04 18:54 [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used james.kanze at gmail dot com
@ 2012-01-04 19:03 ` redi at gcc dot gnu.org
  2012-01-05  8:45 ` james.kanze at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2012-01-04 19:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51755

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-04 19:02:33 UTC ---
also PR 51294


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

* [Bug c++/51755] -Wconversion generates false warnings when the ternary operator is used
  2012-01-04 18:54 [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used james.kanze at gmail dot com
  2012-01-04 19:03 ` [Bug c++/51755] " redi at gcc dot gnu.org
@ 2012-01-05  8:45 ` james.kanze at gmail dot com
  2012-01-05  9:29 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: james.kanze at gmail dot com @ 2012-01-05  8:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51755

--- Comment #2 from James Kanze <james.kanze at gmail dot com> 2012-01-05 08:45:22 UTC ---
I'd miss PR 51294.  My report is almost certainly a duplicate of this one.

It's a minor bug, in that it only affects warnings, but it does make
-Wconversion unusable in certain contexts.


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

* [Bug c++/51755] -Wconversion generates false warnings when the ternary operator is used
  2012-01-04 18:54 [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used james.kanze at gmail dot com
  2012-01-04 19:03 ` [Bug c++/51755] " redi at gcc dot gnu.org
  2012-01-05  8:45 ` james.kanze at gmail dot com
@ 2012-01-05  9:29 ` paolo.carlini at oracle dot com
  2012-01-05 14:12 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-01-05  9:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51755

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |paolo.carlini at oracle dot
                   |                            |com

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-01-05 09:29:02 UTC ---
Hi Jason. Looks like people are really unhappy with the -Wconversion warnings
vs the ternary operator, and I'd like to look into these issues in time for
4.7. At the moment I'm confused, however, because I don't understand if the
patch linked by Manuel in PR51294 (maybe we can consolidate these two issues)
was rejected in a unamendable way, or we (I) can start from it and complete the
work. Can you guide me a bit? Thanks...


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

* [Bug c++/51755] -Wconversion generates false warnings when the ternary operator is used
  2012-01-04 18:54 [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used james.kanze at gmail dot com
                   ` (2 preceding siblings ...)
  2012-01-05  9:29 ` paolo.carlini at oracle dot com
@ 2012-01-05 14:12 ` jason at gcc dot gnu.org
  2012-01-05 15:32 ` manu at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2012-01-05 14:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51755

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2012-01-05 14:11:19 UTC ---
(In reply to comment #3)
> At the moment I'm confused, however, because I don't understand if the
> patch linked by Manuel in PR51294 (maybe we can consolidate these two issues)
> was rejected in a unamendable way, or we (I) can start from it and complete the
> work. Can you guide me a bit? Thanks...

I'm not the one who rejected it, so I don't know what Joseph's thinking is; I'd
suggest responding to his mail.


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

* [Bug c++/51755] -Wconversion generates false warnings when the ternary operator is used
  2012-01-04 18:54 [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used james.kanze at gmail dot com
                   ` (3 preceding siblings ...)
  2012-01-05 14:12 ` jason at gcc dot gnu.org
@ 2012-01-05 15:32 ` manu at gcc dot gnu.org
  2012-01-06 13:14 ` paolo.carlini at oracle dot com
  2012-01-07 13:04 ` manu at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2012-01-05 15:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51755

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |manu at gcc dot gnu.org
         Resolution|                            |DUPLICATE

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-01-05 15:32:03 UTC ---
(In reply to comment #3)
> Hi Jason. Looks like people are really unhappy with the -Wconversion warnings
> vs the ternary operator, and I'd like to look into these issues in time for
> 4.7. At the moment I'm confused, however, because I don't understand if the
> patch linked by Manuel in PR51294 (maybe we can consolidate these two issues)
> was rejected in a unamendable way, or we (I) can start from it and complete the
> work. Can you guide me a bit? Thanks...

In fact, it would be the opposite. Start from it and cut out what Joseph was
against, which is to not warn for char a,b,c; a = b * c, which is what PR40752
asks for. The ternary operator (PR51294) was orthogonal to this issue but the
patch fixed both.

(I wouldn't send a patch like that now, but I was a newbie then.)

I think this is a clearly a duplicate of 51294.

*** This bug has been marked as a duplicate of bug 51294 ***


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

* [Bug c++/51755] -Wconversion generates false warnings when the ternary operator is used
  2012-01-04 18:54 [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used james.kanze at gmail dot com
                   ` (4 preceding siblings ...)
  2012-01-05 15:32 ` manu at gcc dot gnu.org
@ 2012-01-06 13:14 ` paolo.carlini at oracle dot com
  2012-01-07 13:04 ` manu at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-01-06 13:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51755

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-01-06 13:13:41 UTC ---
Thus by 'opposite' of 'complete' you mean that nothing should be *added* to the
patch, instead something removed from it? Great. You see I meant completing
*the work*, thus committing and closing the PR. Anyway, Manuel, would you be
willing to send over a patch answeing Joseph' concerns? Otherwise I'll try to
do it myself, but probably it will take more time because I have start from
scratch on this. Thanks!


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

* [Bug c++/51755] -Wconversion generates false warnings when the ternary operator is used
  2012-01-04 18:54 [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used james.kanze at gmail dot com
                   ` (5 preceding siblings ...)
  2012-01-06 13:14 ` paolo.carlini at oracle dot com
@ 2012-01-07 13:04 ` manu at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2012-01-07 13:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51755

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-01-07 13:03:54 UTC ---
(In reply to comment #6)
> Thus by 'opposite' of 'complete' you mean that nothing should be *added* to the
> patch, instead something removed from it? Great. You see I meant completing

Yes. But probably the patch needs to be substantially changed. And you should
check with Joseph whether he is happy with the additional complexity added.

> *the work*, thus committing and closing the PR. Anyway, Manuel, would you be
> willing to send over a patch answeing Joseph' concerns? Otherwise I'll try to
> do it myself, but probably it will take more time because I have start from
> scratch on this. Thanks!

Sorry, I don't have enough free time to do this. 

Also, I am not sure anymore that it is worth to add these checks to gcc, which
is not meant to be a static analysis tool or be used to build one. GCC FEs are
very limited in the kind of analysis they can make, and this seems to be on
purpose. It would be better to focus on scan-build
http://clang-analyzer.llvm.org/scan-build.html or build a GPL static analyzer
on top of clang.


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

end of thread, other threads:[~2012-01-07 13:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-04 18:54 [Bug c++/51755] New: -Wconversion generates false warnings when the ternary operator is used james.kanze at gmail dot com
2012-01-04 19:03 ` [Bug c++/51755] " redi at gcc dot gnu.org
2012-01-05  8:45 ` james.kanze at gmail dot com
2012-01-05  9:29 ` paolo.carlini at oracle dot com
2012-01-05 14:12 ` jason at gcc dot gnu.org
2012-01-05 15:32 ` manu at gcc dot gnu.org
2012-01-06 13:14 ` paolo.carlini at oracle dot com
2012-01-07 13:04 ` manu 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).