From: "Marko Kreen" <markokr@gmail.com>
To: linux-sparse@vger.kernel.org
Subject: confusing shift warning
Date: Fri, 25 Apr 2008 10:53:08 +0300 [thread overview]
Message-ID: <e51f66da0804250053x2ec991dbu9a5a54fdcbea2a2a@mail.gmail.com> (raw)
Platform: x64_64 linux, uint64_t -> unsigned long
Sparse: today's git (6dcc36a)
Code:
--------------------------------------------
#include <stdint.h>
static void fn1(uint32_t val) { }
static void fn2(uint64_t val)
{
fn1(val >> 32); // warning
}
static void fn3(unsigned int val) { }
static void fn4(unsigned long long val)
{
fn3(val >> 32); // no warning
}
------------------------------
$ cgcc -c test.c
test.c:7:10: warning: shift too big (32) for type unsigned long
-------------------------------
The confusion raises from the fact that "unsigned long" _does_
support 32-bit shift, and anyway I'm using "uint64_t", which
I expect sparse to understand.
Guess - somewhere is hardwired that "long" == "32-bit"?
For reference:
$ cgcc -v -c test.c
sparse -v -c test.c -Dx86_64=1 -D__x86_64=1 -D__x86_64__=1
-D__CHAR_BIT__=8 -D__SCHAR_MAX__=127 -D__SHRT_MAX__=32767
-D__INT_MAX__=2147483647 -D__LONG_MAX__=9223372036854775807L
-D__LONG_LONG_MAX__=9223372036854775807LL -D__FLT_RADIX__=2
-D__FINITE_MATH_ONLY__=0 -D__DECIMAL_DIG__=33 -D__FLT_MANT_DIG__=24
-D__FLT_DIG__=6 -D__FLT_MIN_EXP__='(-125)' -D__FLT_MAX_EXP__=128
-D__FLT_MIN_10_EXP__='(-37)' -D__FLT_MAX_10_EXP__=38
-D__FLT_HAS_INFINITY__=1 -D__FLT_HAS_QUIET_NAN__=1
-D__FLT_DENORM_MIN__=1.40129846e-45F -D__FLT_EPSILON__=1.19209290e-7F
-D__FLT_MAX__=3.40282347e+38F -D__FLT_MIN__=1.17549435e-38F
-D__DBL_MANT_DIG__=53 -D__DBL_DIG__=15 -D__DBL_MIN_EXP__='(-1021)'
-D__DBL_MAX_EXP__=1024 -D__DBL_MIN_10_EXP__='(-307)'
-D__DBL_MAX_10_EXP__=308 -D__DBL_HAS_INFINITY__=1
-D__DBL_HAS_QUIET_NAN__=1 -D__DBL_DENORM_MIN__=4.9406564584124654e-324
-D__DBL_EPSILON__=2.2204460492503131e-16
-D__DBL_MAX__=1.7976931348623157e+308
-D__DBL_MIN__=2.2250738585072014e-308 -D__LDBL_MANT_DIG__=113
-D__LDBL_DIG__=33 -D__LDBL_MIN_EXP__='(-16381)'
-D__LDBL_MAX_EXP__=16384 -D__LDBL_MIN_10_EXP__='(-4931)'
-D__LDBL_MAX_10_EXP__=4932 -D__LDBL_HAS_INFINITY__=1
-D__LDBL_HAS_QUIET_NAN__=1
-D__LDBL_DENORM_MIN__=6.47517511943802511092443895822764655e-4966L
-D__LDBL_EPSILON__=1.92592994438723585305597794258492732e-34L
-D__LDBL_MAX__=1.18973149535723176508575932662800702e+4932L
-D__LDBL_MIN__=3.36210314311209350626267781732175260e-4932L
-U__SIZE_TYPE__ -D__SIZE_TYPE__=long\ unsigned\ int -Dunix=1
-D__unix=1 -D__unix__=1 -D__linux__=1 -D__linux=1 -Dlinux=linux
test.c:7:10: warning: shift too big (32) for type unsigned long
--
marko
next reply other threads:[~2008-04-25 7:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-25 7:53 Marko Kreen [this message]
2008-04-25 8:03 ` confusing shift warning Marko Kreen
[not found] ` <33544769883882222@unknownmsgid>
2008-04-25 8:34 ` Marko Kreen
2008-04-25 8:58 ` Marko Kreen
[not found] ` <-3423297637585954490@unknownmsgid>
2008-04-25 13:37 ` Marko Kreen
[not found] ` <-8184754938437793631@unknownmsgid>
2008-04-25 14:37 ` Marko Kreen
2008-04-25 16:04 ` Pavel Roskin
2008-04-25 17:26 ` Marko Kreen
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=e51f66da0804250053x2ec991dbu9a5a54fdcbea2a2a@mail.gmail.com \
--to=markokr@gmail.com \
--cc=linux-sparse@vger.kernel.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 NNTP newsgroup(s).