linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ftp.linux.org.uk>
To: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linux-sparse@vger.kernel.org, Ben Elliston <elliston@au1.ibm.com>
Subject: Re: [RFC] bloody mess with __attribute__() syntax
Date: Fri, 13 Jul 2007 10:04:22 +0100	[thread overview]
Message-ID: <20070713090422.GA23203@ftp.linux.org.uk> (raw)
In-Reply-To: <20070705162741.GL21478@ftp.linux.org.uk>

[l-k removed from Cc]

	FWIW, I have several problems with that TR.  All of them have the
same root cause: arrays vs. qualifiers.

1) unless 6.7.3[8] is explicitly changed, qualifiers apply to element type
of array; when you manage to apply qualifier to an array (possible via
creative use of typedef), it still applies to the element (i.e. trickles
down until it hits non-array).

2) consequently, changes to 6.2.5 are broken.  They require _any_ array
type T to be in generic address space; of course, this is a nonsense.

3) in changes to 6.7.2.1 (saying that struct or union member types should
not carry an address space qualifier) we have a variant of the same problem -
arrays escape that requirement, but they clearly should not.

4) in places where some attempt to dance around that problem is made,
results are clumsy and actually still wrong.  A typical example:

"The pointer into enclosed address space is first converted to a pointer
to the same reference type except with any address-space qualifier
removed and any address-space qualifer of the other pointer's reference
type added".

We clearly should not replace such qualifiers deep in type derivation.


Now, AFAICS a clean solution would be to leave 6.7.3[8] alone, but
* define 'type T belongs to address space A' by
	if T1 is a type and _A is an address-space qualifier, then 
the type '_A-qualified T1' belongs to corresponding address space.
	if a type T is an array of T1, T belongs to address space A
if and only if T1 belongs to address space A.
* in 6.7.2.1 change the requirement to 'the type of a member shall
not belong to non-generic address space' or equivalent.
* in places dealing with conversion of pointers between address spaces
for comparisons, etc., speak of address-space qualifiers on the outermost
non-array in derivation of reference type.  Might be worth a definition
('counterpart of type T in enclosing address space').

Note that this is very easy to get wrong; similar questions about
const and volatile lead to a subtle difference between C and C++ type
systems and in that particular case C++ one is actually saner.

In C you can assign a pointer to array of const int to object of type
pointer to void, exactly because the constraints refer to qualifiers
on reference type and do not take into account the case when qualifier
sits on array element.  C++ prohibits that - you can assign to const void *,
but not to void *.  I.e. the 'constness' is inherited by arrays there
as far as this kind of implicit conversions is concerned.

For address spaces we definitely want the same kind of semantics;
array elements obviously belong to the same address space as the
array itself.  I have not checked the C++98 (or drafts of C++0x), but
if the construction they are using to describe that part of C++
semantics of const and volatile is not too atrocious it might make
sense to borrow it...

  reply	other threads:[~2007-07-13  9:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-05  9:35 [RFC] bloody mess with __attribute__() syntax Al Viro
2007-07-05 12:03 ` Arnd Bergmann
     [not found]   ` <OFC2AA6078.1DF7BE7E-ON4225730F.0044BE34-4225730F.0046B6F1@de.ibm.com>
2007-07-05 16:27     ` Al Viro
2007-07-13  9:04       ` Al Viro [this message]
2007-07-05 15:36 ` Josh Triplett
2007-07-05 16:43   ` Al Viro
2007-07-05 18:50     ` Josh Triplett
2007-07-05 19:13       ` Al Viro
2007-07-05 19:35         ` Josh Triplett
2007-07-05 20:08           ` Al Viro
2007-07-05 20:56             ` Linus Torvalds
2007-07-06  3:26               ` Al Viro
2007-07-05 21:09             ` Josh Triplett
2007-07-06  7:48       ` Al Viro
2007-07-06  8:33         ` Josh Triplett
2007-07-06 15:52           ` Al Viro
2007-07-06 19:29             ` Josh Triplett
2007-07-07  2:11               ` Al Viro
2007-07-07  2:28                 ` Josh Triplett
2007-07-08 21:50                   ` Al Viro
2007-07-07  2:30                 ` Al Viro
2007-07-07  2:55                   ` Josh Triplett
2007-07-08 21:52                     ` Al Viro
2007-07-05 16:41 ` Linus Torvalds
2007-07-05 16:53   ` Al Viro
2007-07-05 17:02     ` Chris Lattner
2007-07-05 17:09   ` Al Viro
2007-07-05 17:26     ` Linus Torvalds
2007-07-05 18:07       ` Al Viro
2007-07-05 18:56         ` Linus Torvalds

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=20070713090422.GA23203@ftp.linux.org.uk \
    --to=viro@ftp.linux.org.uk \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=arnd@arndb.de \
    --cc=elliston@au1.ibm.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).