Re: Linux without the GNU toolchain?

From: Peter T. Breuer (ptb_at_oboe.it.uc3m.es)
Date: 10/14/05


Date: Fri, 14 Oct 2005 12:36:30 +0200

Chris Barts <chbarts+usenet@gmail.com> wrote:
> Peter T. Breuer wrote:

>>
>> It's simply not likely. This is C, according to gcc:
>>
>>
>> *(4|1) = 5;

> Not according to gcc 4.0.1. I tried to compile a program with that line and
> got the error "invalid type argument of 'unary *'".

Uh, you're right. Throw a cast to int * in there somewhere.

   % cat foo.c
   main() {
     *(int *)(4|1) = 5;
   }
   % gcc foo.c
   %

(gcc 2.95). Basically, calculated lvalues are a11ow3d. A cast should
mean it's an rvalue by definition.

> Variadic macros are standard as of the C standard of 1999, but it's pretty
> dumb to code to that standard if you want code portable to more than a very
> few compilers. Computed gotos, nested functions, and the typeof() macro are
> all nonstandard, nonportable GNU C, however.

Did we mention offsetof()? And all the sizeof() stuff boils down to
__gcc_builtin_sizeof() so it's deeply implementation dependent even
for calculating constants.

Peter



Relevant Pages

  • Re: [PATCH] Make hash.h usable in the kernel
    ... course for the unsafe cast. ... since allowing this is equivalent to allowing casting away of const. ... Maybe gcc is allowing a loophole or just making no more effort than the ... was only the warning for that cast which made hash.h unusable (the original ...
    (freebsd-net)
  • Re: the printk problem
    ... They always need to be cast to `unsiged long long', ... The thing is that GCC checks types. ... We can add an alternative alias to printk: ... and then use printkif you use only standard %fmt (and have it ...
    (Linux-Kernel)
  • Re: 0/1 Knapsack problem, what am I doing wrong
    ... Not using a cast can also turn off a diagnostic in certain situations. ... It shows that gcc does not by default generate the warnings that several people claim that you get from compilers. ... If when people advised casting they also advised making sure that compiler options to enable the warnings for implicit function declarations I would be less concerned about it. ...
    (comp.lang.c)
  • Re: +++i
    ... >initially put into gcc by just ignoring it in almost all aspects. ... >gcc implemented it as a cast in some cases. ... Which, interestingly, throws one back into the strange "implicit ... and invisible cast" discussion. ...
    (comp.lang.c)
  • Re: @@Identity
    ... I have found no other solution to this than to cast the result explicitly. ... I.e. does the from clause increase speed or is ... > The execute scalar still returns a decimal though, and not an INT, ...
    (microsoft.public.sqlserver.ce)