From: David Miller <davem@davemloft.net>
To: Kim.Nordlund@nokia.com
Cc: tgraf@suug.ch, kaber@trash.net, netdev@vger.kernel.org
Subject: Re: [PKT_SCHED] cls_basic: Use unsigned int when generating handle
Date: Wed, 27 Sep 2006 16:18:48 -0700 (PDT) [thread overview]
Message-ID: <20060927.161848.122030745.davem@davemloft.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0609271441390.9010-100000@dhcp09282.ntc.nokia.com>
From: "Nordlund Kim (Nokia-NET/Helsinki)" <Kim.Nordlund@nokia.com>
Date: Wed, 27 Sep 2006 14:45:21 +0300 (EEST)
> But for signed types it falls under this:
>
> 6.5 Expressions
> 5 If an exceptional condition occurs during the evaluation of an
> expression (that is, if the
> result is not mathematically defined or not in the range of
> representable values for its
> type), the behavior is undefined.
>
> Already the initial assignment of 0x80000000 to int falls under this:
>
> 6.3.1.3 Signed and unsigned integers
> 1 When a value with integer type is converted to another integer type
> other than _Bool, if
> the value can be represented by the new type, it is unchanged.
> 2 Otherwise, if the new type is unsigned, the value is converted by
> repeatedly adding or
> subtracting one more than the maximum value that can be represented
> in the new type
> until the value is in the range of the new type.49)
> 3 Otherwise, the new type is signed and the value cannot be
> represented in it; either the
> result is implementation-defined or an implementation-defined signal
> is raised.
>
> Of course it can be argued whether the gcc optimization is sane. But it
> seems not to be wrong, and there is no justification for writing the code
> to be unspecified.
Correct, and actually this undefined behavior turns out to be
critical for several types of loop optimizations which I feel
totally justifies the interpretation gcc is using now.
I'll apply Thomas's original patch, thanks.
next prev parent reply other threads:[~2006-09-27 23:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-26 11:59 [PKT_SCHED] cls_basic: Use unsigned int when generating handle Thomas Graf
2006-09-26 13:32 ` Patrick McHardy
2006-09-26 18:36 ` Thomas Graf
2006-09-27 8:50 ` Nordlund Kim (Nokia-NET/Helsinki)
2006-09-27 9:33 ` Thomas Graf
2006-09-27 9:44 ` Patrick McHardy
2006-09-27 10:09 ` Thomas Graf
2006-09-27 11:45 ` Nordlund Kim (Nokia-NET/Helsinki)
2006-09-27 23:18 ` David Miller [this message]
2006-09-27 23:21 ` David Miller
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=20060927.161848.122030745.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=Kim.Nordlund@nokia.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/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).