[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <m3ve5qk8b5.fsf@maximus.localdomain>
Date: Sat, 19 Jan 2008 00:44:46 +0100
From: Krzysztof Halasa <khc@...waw.pl>
To: J.A. Magallón <jamagallon@....com>
Cc: "Linux-Kernel\, " <linux-kernel@...r.kernel.org>
Subject: Re: Why is the kfree() argument const?
"J.A. Magallón" <jamagallon@....com> writes:
> That's what __attribute__ ((pure)) is for, but if none of the
> functions is pure, the compiler can not be sure about side effects
> and can not reorder things. Don't forget that functions can do
> anything apart from mangling with their arguments.
Though it seems it could legally transform:
void kfree(const int *x);
{
int v, *ptr = malloc(sizeof(int));
*ptr = 51;
v = *ptr;
kfree(ptr);
printf("%d", v);
into:
{
int v, *ptr = malloc(sizeof(int));
*ptr = 51;
kfree(ptr);
v = *ptr;
printf("%d", v);
}
if it knows that malloc generates unaliased pointers, which seems
reasonable in general.
--
Krzysztof Halasa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists