All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: GCC 3.4 Heads-up
@ 2003-12-26 11:02 linux
  2003-12-26 20:05 ` Linus Torvalds
  2003-12-27 16:39 ` Andreas Schwab
  0 siblings, 2 replies; 26+ messages in thread
From: linux @ 2003-12-26 11:02 UTC (permalink / raw)
  To: linux-kernel, torvalds

> Similarly, what the _hell_ does the gcc extension
> 
> 	int a;
> 
> 	(char)a += b;
> 
> really mean? The whole extension is just braindamaged,

It means a = (int)((char)a + b).
(Modulo the fact that the value of the expression is the sum of type
char and not the final value of type int.)

Applied to integer types, it *is* pretty brain damaged.  But applied to
pointer types, it makes a lot more sense.

This is because "a += b" in C is actually "a += b * sizeof(*a)", and
sometimes you want a different *a.

In particular, 1 is a popular value.

Consider the common case of a structure which has a bunch of variable-sized
blocks with a standard header:

struct foo {
	unsigned type, size;
	...
} a;

Then you *do* have to write
	a = (struct foo *)((char *)a + a->size);

and I might argue that

	(char *)a += a->size;

is definitely cleaner.

Or consider the case when the structure doesn't have an explicit size
and you have a big case statement for parsing it:

switch (a->type) {
	case BAR:
		process_bar_chunk(((struct bar *)a)++);
		break;
	case BAZ:
		process_baz_chunk(((struct baz *)a)++);
		break;
	...
};

Isn't that code a bit nicer looking?  I put the redundant parens
in to remind people that I didn't mean to write "(struct bar *)(a++)"
(which also has its legitimate uses).


Necessary, no.  But not "brain damaged", either.
It's well-defined and has legitimate uses.

^ permalink raw reply	[flat|nested] 26+ messages in thread
* GCC 3.4 Heads-up
@ 2003-12-26  1:46 Chris Meadors
  2003-12-26  3:46 ` H. Peter Anvin
  2003-12-30  1:37 ` Rusty Russell
  0 siblings, 2 replies; 26+ messages in thread
From: Chris Meadors @ 2003-12-26  1:46 UTC (permalink / raw)
  To: Linux Kernel

I know it isn't the recommended compiler, heck it isn't even released
yet, but I was messing around with a GCC 3.4 snapshot, and figured I'd
give compiling the 2.6.0 kernel a shot.

Other than the constant barrage of warnings about the use of compound
expressions as lvalues being deprecated* (mostly because of lines 114,
116, and 117 of rcupdate.h, which is included everywhere), the build
goes very well.

It isn't until the final link that I get an error.  It seems that
something goes funny with the ACPI's use of strcpy.  I get undefined
references to strcpy in:  acpi_bus_generate_event (twice),
acpi_power_add, acpi_thermal_add, and acpi_bus_add.  There may be
additional different locations, but the error output stops there.

As I said, I'm just messing around, and figured I'd let everyone know
what's in the pipeline.  But if it is a simple fix, I'll give any
changes anyone wants to try a shot.

*It also doesn't like cast or conditional expressions as lvalues.

-- 
Chris


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2004-01-07  9:56 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <16PqK-8eK-1@gated-at.bofh.it>
     [not found] ` <16RiU-2kO-1@gated-at.bofh.it>
     [not found]   ` <16S5h-3no-5@gated-at.bofh.it>
2004-01-06 21:06     ` GCC 3.4 Heads-up David Mosberger-Tang
2004-01-06 22:33       ` Richard Henderson
2004-01-06 23:23         ` Linus Torvalds
2004-01-07  9:54           ` Richard Henderson
2003-12-26 11:02 linux
2003-12-26 20:05 ` Linus Torvalds
2003-12-27 16:39 ` Andreas Schwab
  -- strict thread matches above, loose matches on Subject: below --
2003-12-26  1:46 Chris Meadors
2003-12-26  3:46 ` H. Peter Anvin
2003-12-26  4:34   ` Linus Torvalds
2003-12-26  6:04     ` H. Peter Anvin
2003-12-26  6:58     ` Andy Isaacson
2003-12-26  7:07       ` H. Peter Anvin
2003-12-26  7:08       ` Linus Torvalds
2003-12-29 16:13       ` David Lloyd
2004-01-02 21:57     ` Bill Davidsen
2004-01-03 21:11       ` Krzysztof Halasa
2004-01-04  5:48         ` Bill Davidsen
2004-01-04 20:41           ` Linus Torvalds
2004-01-05  1:28             ` Bill Davidsen
2004-01-05  1:38               ` Måns Rullgård
2004-01-05 23:49                 ` Ingo Oeser
2004-01-05  2:25               ` Linus Torvalds
2004-01-05  4:15                 ` Bill Davidsen
2004-01-05  4:36                   ` Linus Torvalds
2003-12-30  1:37 ` Rusty Russell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.