public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions
@ 2011-06-13 20:20 dcb314 at hotmail dot com
  2011-06-14 12:48 ` [Bug c/49396] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dcb314 at hotmail dot com @ 2011-06-13 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: c-family/c-cppbuiltin.c: duplicate if expressions
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dcb314@hotmail.com


I just ran the static analysis tool cppcheck-1.49 over the source code
of snapshot 20110611 on a Fedora Linux x86_64 box.

The tool said

[gcc/c-family/c-cppbuiltin.c:562] -> [gcc/c-family/c-cppbuiltin.c:557]: (style)
Found duplicate if expressions.

The source code is

  if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only)
    {
      cpp_undef (pfile, "__FINITE_MATH_ONLY__");
      cpp_define (pfile, "__FINITE_MATH_ONLY__=1");
    }
  else if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only)

I agree with the tool. This looks like a possible cut'n'paste error.
Suggest code rework.


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

* [Bug c/49396] c-family/c-cppbuiltin.c: duplicate if expressions
  2011-06-13 20:20 [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions dcb314 at hotmail dot com
@ 2011-06-14 12:48 ` rguenth at gcc dot gnu.org
  2011-06-14 12:54 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-14 12:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.06.14 12:47:55
                 CC|                            |jsm28 at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-14 12:47:55 UTC ---
I think it should be

Index: c-family/c-cppbuiltin.c
===================================================================
--- c-family/c-cppbuiltin.c     (revision 175011)
+++ c-family/c-cppbuiltin.c     (working copy)
@@ -559,7 +559,7 @@ c_cpp_builtins_optimize_pragma (cpp_read
       cpp_undef (pfile, "__FINITE_MATH_ONLY__");
       cpp_define (pfile, "__FINITE_MATH_ONLY__=1");
     }
-  else if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only)
+  else if (prev->x_flag_finite_math_only && !cur->x_flag_finite_math_only)
     {
       cpp_undef (pfile, "__FINITE_MATH_ONLY__");
       cpp_define (pfile, "__FINITE_MATH_ONLY__=0");

Joseph?


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

* [Bug c/49396] c-family/c-cppbuiltin.c: duplicate if expressions
  2011-06-13 20:20 [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions dcb314 at hotmail dot com
  2011-06-14 12:48 ` [Bug c/49396] " rguenth at gcc dot gnu.org
@ 2011-06-14 12:54 ` rguenth at gcc dot gnu.org
  2011-06-14 13:28 ` joseph at codesourcery dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-14 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-14 12:53:45 UTC ---
Same error on all branches back to 4.4.


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

* [Bug c/49396] c-family/c-cppbuiltin.c: duplicate if expressions
  2011-06-13 20:20 [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions dcb314 at hotmail dot com
  2011-06-14 12:48 ` [Bug c/49396] " rguenth at gcc dot gnu.org
  2011-06-14 12:54 ` rguenth at gcc dot gnu.org
@ 2011-06-14 13:28 ` joseph at codesourcery dot com
  2011-06-14 21:13 ` dcb314 at hotmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2011-06-14 13:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-06-14 13:23:09 UTC ---
On Tue, 14 Jun 2011, rguenth at gcc dot gnu.org wrote:

> I think it should be
> 
> Index: c-family/c-cppbuiltin.c
> ===================================================================
> --- c-family/c-cppbuiltin.c     (revision 175011)
> +++ c-family/c-cppbuiltin.c     (working copy)
> @@ -559,7 +559,7 @@ c_cpp_builtins_optimize_pragma (cpp_read
>        cpp_undef (pfile, "__FINITE_MATH_ONLY__");
>        cpp_define (pfile, "__FINITE_MATH_ONLY__=1");
>      }
> -  else if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only)
> +  else if (prev->x_flag_finite_math_only && !cur->x_flag_finite_math_only)
>      {
>        cpp_undef (pfile, "__FINITE_MATH_ONLY__");
>        cpp_define (pfile, "__FINITE_MATH_ONLY__=0");

Looks right to me.


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

* [Bug c/49396] c-family/c-cppbuiltin.c: duplicate if expressions
  2011-06-13 20:20 [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2011-06-14 13:28 ` joseph at codesourcery dot com
@ 2011-06-14 21:13 ` dcb314 at hotmail dot com
  2011-08-24 10:16 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dcb314 at hotmail dot com @ 2011-06-14 21:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from dcb <dcb314 at hotmail dot com> 2011-06-14 21:13:11 UTC ---
(In reply to comment #2)
> Same error on all branches back to 4.4.

Interesting. Worth generalising so that source code pattern

    if (X)
    {
    }
    else if (X)
    {
    }

would cause a compiler warning ?


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

* [Bug c/49396] c-family/c-cppbuiltin.c: duplicate if expressions
  2011-06-13 20:20 [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2011-06-14 21:13 ` dcb314 at hotmail dot com
@ 2011-08-24 10:16 ` rguenth at gcc dot gnu.org
  2011-08-24 11:28 ` rguenth at gcc dot gnu.org
  2011-08-24 11:29 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-24 10:16 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-24 10:11:55 UTC ---
Mine.  Testing it now, assuming pre-approval (well, it looks obvious anyway).


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

* [Bug c/49396] c-family/c-cppbuiltin.c: duplicate if expressions
  2011-06-13 20:20 [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions dcb314 at hotmail dot com
                   ` (4 preceding siblings ...)
  2011-08-24 10:16 ` rguenth at gcc dot gnu.org
@ 2011-08-24 11:28 ` rguenth at gcc dot gnu.org
  2011-08-24 11:29 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-24 11:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-24 11:17:02 UTC ---
Author: rguenth
Date: Wed Aug 24 11:16:57 2011
New Revision: 178032

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178032
Log:
2011-08-24  Richard Guenther  <rguenther@suse.de>

    PR c/49396

    c-family/
    * c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Fix conditional.

Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-cppbuiltin.c


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

* [Bug c/49396] c-family/c-cppbuiltin.c: duplicate if expressions
  2011-06-13 20:20 [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions dcb314 at hotmail dot com
                   ` (5 preceding siblings ...)
  2011-08-24 11:28 ` rguenth at gcc dot gnu.org
@ 2011-08-24 11:29 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-24 11:29 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-24 11:28:10 UTC ---
Fixed for 4.7.0.


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

end of thread, other threads:[~2011-08-24 11:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-13 20:20 [Bug c/49396] New: c-family/c-cppbuiltin.c: duplicate if expressions dcb314 at hotmail dot com
2011-06-14 12:48 ` [Bug c/49396] " rguenth at gcc dot gnu.org
2011-06-14 12:54 ` rguenth at gcc dot gnu.org
2011-06-14 13:28 ` joseph at codesourcery dot com
2011-06-14 21:13 ` dcb314 at hotmail dot com
2011-08-24 10:16 ` rguenth at gcc dot gnu.org
2011-08-24 11:28 ` rguenth at gcc dot gnu.org
2011-08-24 11:29 ` rguenth 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).