From: Andy H <hutchinsonandy@aim.com>
To: GCC Development <gcc@gcc.gnu.org>
Subject: Whats going on with the conversion warning?
Date: Tue, 20 May 2008 02:20:00 -0000 [thread overview]
Message-ID: <48323573.4030508@aim.com> (raw)
I came across this odd issue with testsuite test Wconversion-5.c and AVR
target.
I should get warning going from a unsigned value that is wider than
signed result.
As I am not skilled in the art of the all conversions rules. I would
appreciate some guidance before I report this as bug.
FYI AVR has 16 bit int, 16 bit short int and 32 bit long.
I extracted the problematic line with a few variants and compiled -O0
and -Wconversion,
void foo(void)
{
signed char sc;
signed char xi;
xi = (int) (unsigned short int) sc; /* testcase NO WARNING - think
this is bug*/
xi = (unsigned short int) sc; /* NO WARNING - think this is bug*/
xi = (long) (unsigned short int) sc; /* warning: conversion to
'signed char' from 'short unsigned int' may alter its value - correct*/
xi = (long) ( short int) sc; /* NO WARNING - correct */
}
It would seem Wconversion:want to see 32bit result before it gives warning.
That can't be right - can it?
best regards
next reply other threads:[~2008-05-20 2:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-20 2:20 Andy H [this message]
2008-05-20 8:33 ` Manuel López-Ibáñez
2008-05-20 23:37 ` Andy H
2008-05-21 0:50 ` Manuel López-Ibáñez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48323573.4030508@aim.com \
--to=hutchinsonandy@aim.com \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).