public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/45780] New: Warning for arithmetic operations involving C99 _Bool variable
@ 2010-09-24 18:40 ubizjak at gmail dot com
  2010-09-24 19:06 ` [Bug c/45780] " ubizjak at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2010-09-24 18:40 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Warning for arithmetic operations involving C99 _Bool
                    variable
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ubizjak@gmail.com


Pasted from the thread that introduced _Bool in place of "GCC bool":

<quote>

> >> It can be done ultimately, but as a prerequisite, we should have
> >> warnings in -Wextra for all of
> >>
> >> ? boolvar++; ++boolvar;
> >> ? boolvar--; --boolvar;
> >> ? boolvar = nonbool;
> >> ? boolvar & nonbool; boolvar &= nonbool;
> >> ? boolvar | nonbool; boolvar |= nonbool;
> >> ? boolvar ^ nonbool; boolvar ^= nonbool;
> >
> > Fair enough. I have CCed Manuel, perhaps he is interested in this warning.
> 
> I am not sure it fits in -Wconversion. -Wbool-arith perhaps?

It sounds like a warning for a -Wc90-c99-compat or similar option 
(possibly in a more specific option such as -Wbool-arith) - pure C99 code 
has little use for such a warning, it's about code that might be compiled 
either with C99 _Bool, or with C90 unsigned char, and so needs to avoid 
cases where they are incompatible.  Such an option, similar in spirit to 
-Wtraditional, could also allow you to get warnings in C99 mode for things 
currently diagnosed with -std=c90 -pedantic.

</quote>

[1] http://gcc.gnu.org/ml/gcc-patches/2010-09/msg01941.html

-- 
Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c/45780] Warning for arithmetic operations involving C99 _Bool variable
  2010-09-24 18:40 [Bug c/45780] New: Warning for arithmetic operations involving C99 _Bool variable ubizjak at gmail dot com
@ 2010-09-24 19:06 ` ubizjak at gmail dot com
  2010-11-03 20:05 ` ericb at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2010-09-24 19:06 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2010.09.24 18:44:45
               date|                            |
            Version|4.5.2                       |unknown
     Ever Confirmed|0                           |1

-- 
Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c/45780] Warning for arithmetic operations involving C99 _Bool variable
  2010-09-24 18:40 [Bug c/45780] New: Warning for arithmetic operations involving C99 _Bool variable ubizjak at gmail dot com
  2010-09-24 19:06 ` [Bug c/45780] " ubizjak at gmail dot com
@ 2010-11-03 20:05 ` ericb at gcc dot gnu.org
  2015-05-28 18:54 ` egall at gwmail dot gwu.edu
  2015-05-29  2:29 ` egall at gwmail dot gwu.edu
  3 siblings, 0 replies; 5+ messages in thread
From: ericb at gcc dot gnu.org @ 2010-11-03 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Blake <ericb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ericb at gcc dot gnu.org

--- Comment #1 from Eric Blake <ericb at gcc dot gnu.org> 2010-11-03 20:05:00 UTC ---
Don't forget a warning on implicit conversions from int to bool, such as:

bool f(int i) { return i; }

although it might make sense to avoid warnings on provably 0/1 int conversion
to bool, as in:

bool f(int i) { i = !!i; return i; }


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

* [Bug c/45780] Warning for arithmetic operations involving C99 _Bool variable
  2010-09-24 18:40 [Bug c/45780] New: Warning for arithmetic operations involving C99 _Bool variable ubizjak at gmail dot com
  2010-09-24 19:06 ` [Bug c/45780] " ubizjak at gmail dot com
  2010-11-03 20:05 ` ericb at gcc dot gnu.org
@ 2015-05-28 18:54 ` egall at gwmail dot gwu.edu
  2015-05-29  2:29 ` egall at gwmail dot gwu.edu
  3 siblings, 0 replies; 5+ messages in thread
From: egall at gwmail dot gwu.edu @ 2015-05-28 18:54 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egall at gwmail dot gwu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egall at gwmail dot gwu.edu

--- Comment #2 from Eric Gallager <egall at gwmail dot gwu.edu> ---
The -Wc90-c99-compat that made it into gcc5 currently warns about any usage of
bool whatsoever, not just the specific usages of bool listed in this bug...


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

* [Bug c/45780] Warning for arithmetic operations involving C99 _Bool variable
  2010-09-24 18:40 [Bug c/45780] New: Warning for arithmetic operations involving C99 _Bool variable ubizjak at gmail dot com
                   ` (2 preceding siblings ...)
  2015-05-28 18:54 ` egall at gwmail dot gwu.edu
@ 2015-05-29  2:29 ` egall at gwmail dot gwu.edu
  3 siblings, 0 replies; 5+ messages in thread
From: egall at gwmail dot gwu.edu @ 2015-05-29  2:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Eric Gallager <egall at gwmail dot gwu.edu> ---
(In reply to Marek Polacek from comment #3)
> (In reply to Eric Gallager from comment #2)
> > The -Wc90-c99-compat that made it into gcc5 currently warns about
> > any usage of bool whatsoever, not just the specific usages of bool
> > listed in this bug...
> 
> Right, that was the point of it.

...so is this bug worth keeping open then? It'd seem kinda redundant to me for
extra, more-specific warnings about bools to be placed in -Wc90-c99-compat (as
was originally proposed), when the flag already prints the more-generalized
warnings that it currently does. Or would they get their own separate
-Wbool-arith option? If so, what would happen when a user specifies both a
hypothetical -Wbool-arith flag along with -Wc90-c99-compat at the same time?
I'm just kinda worried that such a situation could lead to duplicated and/or
excessive warnings...


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

end of thread, other threads:[~2015-05-29  2:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-24 18:40 [Bug c/45780] New: Warning for arithmetic operations involving C99 _Bool variable ubizjak at gmail dot com
2010-09-24 19:06 ` [Bug c/45780] " ubizjak at gmail dot com
2010-11-03 20:05 ` ericb at gcc dot gnu.org
2015-05-28 18:54 ` egall at gwmail dot gwu.edu
2015-05-29  2:29 ` egall at gwmail dot gwu.edu

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).