Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Experiences using "register"

Reply
Thread Tools

Experiences using "register"

 
 
Herbert Rosenau
Guest
Posts: n/a
 
      03-31-2008
On Sat, 29 Mar 2008 17:44:21 UTC, Ioannis Vranos
<(E-Mail Removed)> wrote:

> "register" is part of the language standard, if a compiler considers it
> unneeded, it is free to ignore it. Proper uses of "register" making the
> compiler to produce less-efficient code than not using it at all, is a
> compiler-defect.


Yes, but since C98/99 its free to the compiler simply ignoring
'register'. That means it is the right to the compiler to replace the
keyword register with white space.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!
 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      03-31-2008
Herbert Rosenau wrote, On 31/03/08 20:22:
> On Sat, 29 Mar 2008 17:44:21 UTC, Ioannis Vranos
> <(E-Mail Removed)> wrote:
>
>> "register" is part of the language standard, if a compiler considers it
>> unneeded, it is free to ignore it. Proper uses of "register" making the
>> compiler to produce less-efficient code than not using it at all, is a
>> compiler-defect.

>
> Yes, but since C98/99 its free to the compiler simply ignoring
> 'register'. That means it is the right to the compiler to replace the
> keyword register with white space.


Not quite. If you attempt to take the address of a register variable the
compiler is required to produce a diagnostic. Apart from that, just it
can ignore it.

Oh, and I assume you meant C89 not C98 since I don't believe this has
changed.
--
Flash Gordon
 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      03-31-2008
Flash Gordon wrote:
> Herbert Rosenau wrote, On 31/03/08 20:22:
>> On Sat, 29 Mar 2008 17:44:21 UTC, Ioannis Vranos
>> <(E-Mail Removed)> wrote:
>>
>>> "register" is part of the language standard, if a compiler considers it
>>> unneeded, it is free to ignore it. Proper uses of "register" making the
>>> compiler to produce less-efficient code than not using it at all, is a
>>> compiler-defect.

>>
>> Yes, but since C98/99 its free to the compiler simply ignoring
>> 'register'. That means it is the right to the compiler to replace the
>> keyword register with white space.

>
> Not quite. If you attempt to take the address of a register variable the
> compiler is required to produce a diagnostic. Apart from that, just it
> can ignore it.


Another corner case:

int x = 42;

int f(void) {
register x = 27;
return x;
}

int g(void) {
/*register*/ x = 27;
return x;
}

The two functions do different things.

--
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      03-31-2008
Eric Sosman wrote:
> Flash Gordon wrote:
>> Herbert Rosenau wrote, On 31/03/08 20:22:
>>> On Sat, 29 Mar 2008 17:44:21 UTC, Ioannis Vranos
>>> <(E-Mail Removed)> wrote:
>>>
>>>> "register" is part of the language standard, if a compiler considers it
>>>> unneeded, it is free to ignore it. Proper uses of "register" making the
>>>> compiler to produce less-efficient code than not using it at all, is a
>>>> compiler-defect.
>>>
>>> Yes, but since C98/99 its free to the compiler simply ignoring
>>> 'register'. That means it is the right to the compiler to replace the
>>> keyword register with white space.

>>
>> Not quite. If you attempt to take the address of a register variable
>> the compiler is required to produce a diagnostic. Apart from that,
>> just it can ignore it.

>
> Another corner case:
>
> int x = 42;
>
> int f(void) {
> register x = 27;
> return x;
> }
>
> int g(void) {
> /*register*/ x = 27;
> return x;
> }
>
> The two functions do different things.



Yes, in the second case, x is in file or global scope. What is your point?

 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      03-31-2008
Ioannis Vranos wrote, On 31/03/08 22:56:
> Eric Sosman wrote:
>> Flash Gordon wrote:
>>> Herbert Rosenau wrote, On 31/03/08 20:22:
>>>> On Sat, 29 Mar 2008 17:44:21 UTC, Ioannis Vranos
>>>> <(E-Mail Removed)> wrote:
>>>>
>>>>> "register" is part of the language standard, if a compiler considers it
>>>>> unneeded, it is free to ignore it. Proper uses of "register" making the
>>>>> compiler to produce less-efficient code than not using it at all, is a
>>>>> compiler-defect.
>>>> Yes, but since C98/99 its free to the compiler simply ignoring
>>>> 'register'. That means it is the right to the compiler to replace the

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^
>>>> keyword register with white space.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> Not quite. If you attempt to take the address of a register variable
>>> the compiler is required to produce a diagnostic. Apart from that,
>>> just it can ignore it.

>> Another corner case:
>>
>> int x = 42;
>>
>> int f(void) {
>> register x = 27;
>> return x;
>> }
>>
>> int g(void) {
>> /*register*/ x = 27;
>> return x;
>> }
>>
>> The two functions do different things.

>
> Yes, in the second case, x is in file or global scope. What is your point?


The point is that what Herbert wrote was incorrect for at least two reasons.
--
Flash Gordon
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      03-31-2008
Flash Gordon wrote:
> Ioannis Vranos wrote, On 31/03/08 22:56:
>> Eric Sosman wrote:
>>> Flash Gordon wrote:
>>>> Herbert Rosenau wrote, On 31/03/08 20:22:
>>>>> On Sat, 29 Mar 2008 17:44:21 UTC, Ioannis Vranos
>>>>> <(E-Mail Removed)> wrote:
>>>>>
>>>>>> "register" is part of the language standard, if a compiler
>>>>>> considers it
>>>>>> unneeded, it is free to ignore it. Proper uses of "register"
>>>>>> making the
>>>>>> compiler to produce less-efficient code than not using it at all,
>>>>>> is a
>>>>>> compiler-defect.
>>>>> Yes, but since C98/99 its free to the compiler simply ignoring
>>>>> 'register'. That means it is the right to the compiler to replace the

> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^
>>>>> keyword register with white space.

> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>> Not quite. If you attempt to take the address of a register variable
>>>> the compiler is required to produce a diagnostic. Apart from that,
>>>> just it can ignore it.
>>> Another corner case:
>>>
>>> int x = 42;
>>>
>>> int f(void) {
>>> register x = 27;
>>> return x;
>>> }
>>>
>>> int g(void) {
>>> /*register*/ x = 27;
>>> return x;
>>> }
>>>
>>> The two functions do different things.

>>
>> Yes, in the second case, x is in file or global scope. What is your
>> point?

>
> The point is that what Herbert wrote was incorrect for at least two
> reasons.



Ah right. You are probably referring to C95 implicit int. So in
C99/C++98 the above would be register int x= 47;
 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      04-01-2008
Ioannis Vranos wrote, On 01/04/08 00:20:
> Flash Gordon wrote:
>> Ioannis Vranos wrote, On 31/03/08 22:56:
>>> Eric Sosman wrote:
>>>> Flash Gordon wrote:
>>>>> Herbert Rosenau wrote, On 31/03/08 20:22:
>>>>>> On Sat, 29 Mar 2008 17:44:21 UTC, Ioannis Vranos
>>>>>> <(E-Mail Removed)> wrote:
>>>>>>
>>>>>>> "register" is part of the language standard, if a compiler
>>>>>>> considers it
>>>>>>> unneeded, it is free to ignore it. Proper uses of "register"
>>>>>>> making the
>>>>>>> compiler to produce less-efficient code than not using it at all,
>>>>>>> is a
>>>>>>> compiler-defect.
>>>>>> Yes, but since C98/99 its free to the compiler simply ignoring
>>>>>> 'register'. That means it is the right to the compiler to replace the

>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^
>>>>>> keyword register with white space.

>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>> Not quite. If you attempt to take the address of a register variable
>>>>> the compiler is required to produce a diagnostic. Apart from that,
>>>>> just it can ignore it.
>>>> Another corner case:
>>>>
>>>> int x = 42;
>>>>
>>>> int f(void) {
>>>> register x = 27;
>>>> return x;
>>>> }
>>>>
>>>> int g(void) {
>>>> /*register*/ x = 27;
>>>> return x;
>>>> }
>>>>
>>>> The two functions do different things.
>>> Yes, in the second case, x is in file or global scope. What is your
>>> point?

>> The point is that what Herbert wrote was incorrect for at least two
>> reasons.

>
> Ah right. You are probably referring to C95 implicit int. So in
> C99/C++98 the above would be register int x= 47;


Eric was using implicit int and therefore not C99 but my point stands
for all versions of the standard.
register int i;
/*register*/ int j;
&i; /* diagnostic required */
&j; /* no diagnostic required */
--
Flash Gordon
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      04-01-2008
Ioannis Vranos <(E-Mail Removed)> writes:
> Flash Gordon wrote:
>> Ioannis Vranos wrote, On 31/03/08 22:56:
>>> Eric Sosman wrote:
>>>> Flash Gordon wrote:
>>>>> Herbert Rosenau wrote, On 31/03/08 20:22:

[...]
>>>>>> Yes, but since C98/99 its free to the compiler simply ignoring
>>>>>> 'register'. That means it is the right to the compiler to replace the

>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^
>>>>>> keyword register with white space.

>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>> Not quite. If you attempt to take the address of a register variable
>>>>> the compiler is required to produce a diagnostic. Apart from that,
>>>>> just it can ignore it.
>>>> Another corner case:
>>>>
>>>> int x = 42;
>>>>
>>>> int f(void) {
>>>> register x = 27;
>>>> return x;
>>>> }
>>>>
>>>> int g(void) {
>>>> /*register*/ x = 27;
>>>> return x;
>>>> }
>>>>
>>>> The two functions do different things.
>>>
>>> Yes, in the second case, x is in file or global scope. What is your
>>> point?

>>
>> The point is that what Herbert wrote was incorrect for at least two
>> reasons.

>
> Ah right. You are probably referring to C95 implicit int. So in
> C99/C++98 the above would be register int x= 47;


Well, in C99 it wouldn't exist, since the issue being illustrated
doesn't apply to C99.

--
Keith Thompson (The_Other_Keith) <(E-Mail Removed)>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What are your experiences with ASA 5500 series vs using seperate devices Ned Cisco 1 11-15-2006 08:16 PM
My Experiences with the XFX 7800GTX @ ThinkComputers.org Silverstrand Front Page News 0 09-03-2005 01:41 PM
Who's using VoIP and what your experiences? Marc Computer Support 3 06-03-2005 02:27 AM
Experiences using Canon F/1.4 50mm on 20D? John A. Stovall Digital Photography 3 02-26-2005 11:04 AM
similar experiences? Will Gortoa Firefox 9 11-24-2004 12:46 AM



Advertisments