public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56908] New: Spurious warning when XOR-ing uint8_t values
@ 2013-04-10 15:48 hniksic at gmail dot com
2014-07-09 22:43 ` [Bug c++/56908] " manu at gcc dot gnu.org
2024-04-05 23:10 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: hniksic at gmail dot com @ 2013-04-10 15:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56908
Bug #: 56908
Summary: Spurious warning when XOR-ing uint8_t values
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: hniksic@gmail.com
g++ -Wconversion displays what I believe is a spurious warning in my code:
warning: conversion to 'uint8_t {aka unsigned char}' from 'int' may alter its
value [-Wconversion]
-Wconversion is mandated by the project I'm working on. Since I'm striving for
warningless compilation, I looked into the function. Even after a careful
examination, I cannot find fault with it, nor an obvious way to get rid of the
warning without compromising the code's readability. The minimal example that
warns is:
#include <stdint.h>
#include <stddef.h>
void
xorblock(uint8_t* dest, const uint8_t* src, size_t len)
{
while (len--)
*dest++ ^= *src++;
}
Compiled with g++ -Wconversion a.cc, it prints the warning as:
a.cc: In function 'void xorblock(uint8_t*, const uint8_t*, size_t)':
a.cc:8:20: warning: conversion to 'uint8_t {aka unsigned char}' from 'int' may
alter its value [-Wconversion]
Both operands have the same type, which is appropriate for the calculation.
Casting the right-hand side of the compound assignment to either int, uint8_t,
or unsigned int fails to silence the warning. The warning does not occur with
gcc, only with g++.
The only way I found to remove the warning is to rewrite the assignment as a
non-compound assignment. But this precludes the use of the post-increment
operator and consequently makes the function harder to follow. (In this case
shorter is more readable, as *dest++ = *src++ is one of the most widely
understood C idioms.)
The warning happens with g++ 4.7 and 4.8, but not with g++ 4.6 series.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/56908] Spurious warning when XOR-ing uint8_t values
2013-04-10 15:48 [Bug c++/56908] New: Spurious warning when XOR-ing uint8_t values hniksic at gmail dot com
@ 2014-07-09 22:43 ` manu at gcc dot gnu.org
2024-04-05 23:10 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: manu at gcc dot gnu.org @ 2014-07-09 22:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56908
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-07-09
CC| |manu at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Confirmed, perhaps a regression. More analysis here:
https://gcc.gnu.org/ml/gcc-help/2014-07/msg00042.html
>From gcc-bugs-return-456001-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Jul 09 22:45:24 2014
Return-Path: <gcc-bugs-return-456001-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 11885 invoked by alias); 9 Jul 2014 22:45:23 -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 11799 invoked by uid 55); 9 Jul 2014 22:45:18 -0000
From: "paolo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60686] message "=?UTF-8?Q? only declarations of constructors can be ‘explicit’ ?=" now conflicting with C++11
Date: Wed, 09 Jul 2014 22:45:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: minor
X-Bugzilla-Who: paolo at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-60686-4-oe8a0tCaGb@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60686-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60686-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-07/txt/msg00592.txt.bz2
Content-length: 792
https://gcc.gnu.org/bugzilla/show_bug.cgi?id`686
--- Comment #3 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Wed Jul 9 22:44:42 2014
New Revision: 212415
URL: https://gcc.gnu.org/viewcvs?rev!2415&root=gcc&view=rev
Log:
/cp
2014-07-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60686
* decl.c (grokdeclarator): Adjust error messages about 'explicit'
outside class declaration, in friend declaration, and neither on
constructor nor conversion operator.
/testsuite
2014-07-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60686
* g++.dg/cpp0x/explicit8.C: New.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/explicit8.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/56908] Spurious warning when XOR-ing uint8_t values
2013-04-10 15:48 [Bug c++/56908] New: Spurious warning when XOR-ing uint8_t values hniksic at gmail dot com
2014-07-09 22:43 ` [Bug c++/56908] " manu at gcc dot gnu.org
@ 2024-04-05 23:10 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-05 23:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56908
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
Target Milestone|--- |10.0
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=91993
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 10.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-05 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10 15:48 [Bug c++/56908] New: Spurious warning when XOR-ing uint8_t values hniksic at gmail dot com
2014-07-09 22:43 ` [Bug c++/56908] " manu at gcc dot gnu.org
2024-04-05 23:10 ` pinskia 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).