From: Al Viro <viro@ftp.linux.org.uk>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Roland Dreier <rdreier@cisco.com>, Andrew Morton <akpm@osdl.org>,
David Miller <davem@davemloft.net>,
linux-kernel@vger.kernel.org, openib-general@openib.org,
tom@opengridcomputing.com, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] Avoid truncating to 'long' in ALIGN() macro
Date: Mon, 27 Nov 2006 04:41:39 +0000 [thread overview]
Message-ID: <20061127044138.GA3078@ftp.linux.org.uk> (raw)
In-Reply-To: <Pine.LNX.4.64.0611261415530.3483@woody.osdl.org>
On Sun, Nov 26, 2006 at 02:20:10PM -0800, Linus Torvalds wrote:
> So arguably, the result is _more_ like a normal C operation this way.
> Type-wise, the "ALIGN()" macro acts like any other C operation (ie if you
> feed it an "unsigned char", the end result is an "int" due to the normal C
> type widening that happens for all C operations).
>
> But I don't care horribly much. Al may have some other reasons to _not_
> want the normal C type expansion to happen (ie maybe he does something
> unnatural with sparse ;)
Type expansion will happen as soon as you do any arithmetics (or passing
as argument) anyway.
It's actually more of "typeof() has interesting interactions with
other gccisms" kind of thing and general dislike of using that beast
more than absolutely necessary.
Not the #1 on my list of the worst gccisms we are using (that would be
({...}) with its insane semantics and interesting ways to get gcc puke
its guts out), but still pretty high there...
ObFun: what's the type of ({struct {int x,y;} a = {1,2}; a;}) and
how comes that we can say
({struct {int x,y;} a = {1,2}; a;}).y
and get gcc eat it up and evaluate that to 2? Note that we are doing
a very obvious violation of scope rules - WTF _is_ .y in scope where
we have no visible declaration of any structure with field that would
have such name?
IOW, gcc allows type to leak out of scope it's been defined in (and
typeof adds even more fun to the picture). It not only goes against
a _lot_ in C, it's actually not thought through by gcc folks. Just
try to mix that with variable-length arrays and watch it blow up
in interesting ways...
next prev parent reply other threads:[~2006-11-27 4:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-25 5:40 [PATCH] Avoid truncating to 'long' in ALIGN() macro Roland Dreier
2006-11-25 6:07 ` David Miller
2006-11-25 22:56 ` Roland Dreier
2006-11-25 23:05 ` David Miller
2006-11-25 23:09 ` Roland Dreier
2006-11-26 0:41 ` Andrew Morton
2006-11-26 19:09 ` Roland Dreier
2006-11-26 19:10 ` Roland Dreier
2006-11-26 19:17 ` Andrew Morton
2006-11-26 20:06 ` Roland Dreier
2006-11-26 20:11 ` Linus Torvalds
2006-11-26 20:26 ` Roland Dreier
2006-11-26 21:06 ` Jörn Engel
2006-11-26 22:20 ` Linus Torvalds
2006-11-27 4:41 ` Al Viro [this message]
2006-11-26 1:10 ` Al Viro
2006-11-26 1:17 ` Roland Dreier
2006-11-26 1:25 ` Al Viro
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=20061127044138.GA3078@ftp.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=openib-general@openib.org \
--cc=rdreier@cisco.com \
--cc=tom@opengridcomputing.com \
--cc=torvalds@osdl.org \
--cc=viro@zeniv.linux.org.uk \
/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