public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/64439] New: Incorrect location of -Wunused-value or false negative
@ 2014-12-29 19:46 chengniansun at gmail dot com
  2014-12-29 23:44 ` [Bug c/64439] " manu at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: chengniansun at gmail dot com @ 2014-12-29 19:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64439
           Summary: Incorrect location of -Wunused-value or false negative
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

For the expression "a && ((b = 0) != 0)", GCC warns that the expression value
"((b = 0) != 0)" is not used. Should it point to the whole expression rather
this sub-expression? Or this is a false negative of -Wunused-value?


$: cat s.c 
void f(int a, int b) { 
  a && ((b = 0) != 0); 
}
$: 
$: gcc-trunk -c -Wunused-value s.c 
s.c: In function ‘f’:
s.c:2:17: warning: value computed is not used [-Wunused-value]
   a && ((b = 0) != 0); 
                 ^
$: 
$: clang-trunk -c -Wunused-value s.c
s.c:2:5: warning: expression result unused [-Wunused-value]
  a && ((b = 0) != 0); 
  ~ ^  ~~~~~~~~~~~~~~
1 warning generated.
$: 
$:
>From gcc-bugs-return-471897-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Dec 29 19:54:43 2014
Return-Path: <gcc-bugs-return-471897-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21666 invoked by alias); 29 Dec 2014 19:54:43 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 21631 invoked by uid 48); 29 Dec 2014 19:54:38 -0000
From: "anlauf at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/64432] [5 Regression] SYSTEM_CLOCK(COUNT_RATE=rate) wrong result for integer(4)::rate
Date: Mon, 29 Dec 2014 19:54:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: anlauf at gmx dot de
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: fxcoudert at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-64432-4-NcbGUEwKsl@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64432-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64432-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-12/txt/msg02904.txt.bz2
Content-length: 1692

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd432

--- Comment #7 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Harald Anlauf from comment #5)
> (In reply to Francois-Xavier Coudert from comment #4)
> > If you have another idea, please post a list of what you think should happen
> > in all various cases (all possible combinations of arguments have to be
> > allowed).
>
> Let's see:
>
> - For any number of arguments present (1, 2 or 3)
>   - always integer(4): msec resolution (as before)
>   - always integer(>=8): usec resolution (or whatever is possible)
>   - always real: I don't care, but I think it might be a good idea
>     to use the same as for integer of a compatible kind.
>   - different types and/or kinds: I don't care, since one should
>     expect problems (wrapping or truncation) anyway.
>
> But presence of non-presence should never make a difference
> if consistent types and kinds are used.

I played around with other compilers and posted the result at:

https://groups.google.com/forum/?hl=en#!topic/comp.lang.fortran/5aoFFRNBP0g

The only compiler that allows for different timer resolutions and
produces an at least self-consistent result appears to be Intel.
It actually treats each argument separately: if it is a 4-byte
argument, it returns values referring to the low-res (0.1 msec) version;
for an 8-byte argument one gets the high-res (1 usec) version.
(Confirmed by looking at the explicit assembler code).

That would be even simpler than any of the versions I discussed above.

The actual implementation then might generate a call to
_gfortran_system_clock_{4,8} for each present argument,
with the respective kind taken into account.


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

* [Bug c/64439] Incorrect location of -Wunused-value or false negative
  2014-12-29 19:46 [Bug c/64439] New: Incorrect location of -Wunused-value or false negative chengniansun at gmail dot com
@ 2014-12-29 23:44 ` manu at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: manu at gcc dot gnu.org @ 2014-12-29 23:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
It doesn't seem a false negative to me. 

It is a bit strange that we get different locations for equivalent expressions:

s.c:2:17: warning: value computed is not used [-Wunused-value]
   a && ((b = 0) != 0); 
                 ^
s.c:3:18: warning: value computed is not used [-Wunused-value]
   ((b = 0) != 0) && a;
                  ^

But I'm not sure if it is a bug. Someone would need to look at gcc while
compiling the testcase under a debugger to understand why the difference exists
at all.
>From gcc-bugs-return-471911-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Dec 29 23:59:00 2014
Return-Path: <gcc-bugs-return-471911-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 15876 invoked by alias); 29 Dec 2014 23:58:57 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 15858 invoked by uid 48); 29 Dec 2014 23:58:50 -0000
From: "dark_footix at yahoo dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug regression/64437] hang with iconv on the configure : "checking whether the C compiler works"
Date: Mon, 29 Dec 2014 23:58:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: regression
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dark_footix at yahoo dot fr
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-64437-4-bHaiwUNFBN@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64437-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64437-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-12/txt/msg02918.txt.bz2
Content-length: 496

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd437

fredm <dark_footix at yahoo dot fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from fredm <dark_footix at yahoo dot fr> ---
Sorry, I did a mismatch of pre build lib with my previous toolchain

This bug is closed


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

end of thread, other threads:[~2014-12-29 23:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-29 19:46 [Bug c/64439] New: Incorrect location of -Wunused-value or false negative chengniansun at gmail dot com
2014-12-29 23:44 ` [Bug c/64439] " 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).