Account Options

  1. Sign in
Google Groups Home
« Groups Home
Message from discussion Missing constraints?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Clive D. W. Feather  
View profile  
 More options Jul 16 2003, 7:09 am
Newsgroups: comp.std.c
From: "Clive D. W. Feather" <cl...@on-the-train.demon.co.uk>
Date: Wed, 16 Jul 2003 09:43:35 +0100
Local: Wed, Jul 16 2003 4:43 am
Subject: Re: Missing constraints?
In article <bf1d6c$11f...@cuce.ruk.cuni.cz>, Miloslav Trmac
<tr...@popelka.ms.mff.cuni.cz> writes

>Hello,
>Another two questions.

>First, which constraint does the following translation unit violate?
>       typedef int i = 5;
>AFAICS none of 6.7, 6.7.7 and 6.7.8 prohibits this explicitly.

6.7.8:
    [#2] No initializer shall attempt to provide a value for  an
    object not contained within the entity being initialized.

Since "i" is not an object, any initializer will be attempting to
initialize an object not contained within it.

There was a loose proposal to allow this as an extension. Under it,
anything declared with "i" rather than "int" would be initialized to 5
if no initializer was given.

>Second, by current rules, the following two external declarations do not
>violate any constraint:
>       int n, i;
>       int *p = (int *)(int (*)[n])&i;
>(that is, address constant can contain casts to VM types). I can live
>with that, I just wonder whether this is intentionally allowed.
>(Yes, the cast may invoke UB, but I believe that's not relevant here).

As far as I can see, it's allowed. However, I'm not sure if it should
be: consider:

    int *p = (int *)(int (*)[n][n])&i;

where the size of the second dimension affects something like alignment.

--
Clive D.W. Feather, writing for himself  | Home: <cl...@davros.org>
Tel: +44 20 8371 1138 (work)             | Web:  <http://www.davros.org>
Fax: +44 870 051 9937                    | Work: <cl...@demon.net>
Written on my laptop; please observe the Reply-To address


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.