Re: Why is the kfree() argument const?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Vadim Lobanov
Date: Friday, January 18, 2008 - 12:55 pm

On Friday 18 January 2008 11:31:05 am Zan Lynx wrote:

Oh, absolutely. The problem, however, is that very very few people actually 
use these function attributes in their code. Heck, we don't even use the 
standard restrict keyword, much less gcc-specific function annotations.

I think that one part of the problem is because gcc seems to have had 
attribute diarrhea -- I know of noone who can recite more than 10% of the 
available attributes without glancing at the documentation. The other part of 
the problem is that gcc does no sanity checks on the provided attributes. For 
example, the code below compiles perfectly fine without a peep, even 
with -Wall and -Wextra.

int global;

void foobar(const int *x) __attribute__((const));

void foobar(const int *x)
{
        if (*x)
                *(int *)x = 7;
        global = 11;
}

*grumble, grumble* :-)

-- Vadim Lobanov
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
RE: Why is the kfree() argument const?, Linus Torvalds, (Thu Jan 17, 2:25 pm)
RE: Why is the kfree() argument const?, David Schwartz, (Thu Jan 17, 3:28 pm)
RE: Why is the kfree() argument const?, Linus Torvalds, (Thu Jan 17, 4:10 pm)
RE: Why is the kfree() argument const?, David Schwartz, (Thu Jan 17, 5:56 pm)
RE: Why is the kfree() argument const?, Linus Torvalds, (Thu Jan 17, 6:15 pm)
RE: Why is the kfree() argument const?, David Schwartz, (Thu Jan 17, 10:02 pm)
Re: Why is the kfree() argument const?, Giacomo Catenazzi, (Fri Jan 18, 1:20 am)
Re: Why is the kfree() argument const?, Vadim Lobanov, (Fri Jan 18, 1:30 am)
Re: Why is the kfree() argument const?, Giacomo A. Catenazzi, (Fri Jan 18, 4:47 am)
Re: Why is the kfree() argument const?, Björn, (Fri Jan 18, 6:31 am)
Re: Why is the kfree() argument const?, Andy Lutomirski, (Fri Jan 18, 6:53 am)
Re: Why is the kfree() argument const?, Andy Lutomirski, (Fri Jan 18, 6:54 am)
Re: Why is the kfree() argument const?, Jakob Oestergaard, (Fri Jan 18, 7:39 am)
Re: Why is the kfree() argument const?, Chris Friesen, (Fri Jan 18, 8:38 am)
RE: Why is the kfree() argument const?, Linus Torvalds, (Fri Jan 18, 9:10 am)
Re: Why is the kfree() argument const?, Olivier Galibert, (Fri Jan 18, 10:24 am)
Re: Why is the kfree() argument const?, Olivier Galibert, (Fri Jan 18, 10:37 am)
Re: Why is the kfree() argument const?, DM, (Fri Jan 18, 11:06 am)
Re: Why is the kfree() argument const?, Vadim Lobanov, (Fri Jan 18, 12:06 pm)
Re: Why is the kfree() argument const?, Vadim Lobanov, (Fri Jan 18, 12:14 pm)
Re: Why is the kfree() argument const?, Vadim Lobanov, (Fri Jan 18, 12:55 pm)
RE: Why is the kfree() argument const?, David Schwartz, (Fri Jan 18, 1:55 pm)
Re: Why is the kfree() argument const?, J.A. , (Fri Jan 18, 3:29 pm)
Re: Why is the kfree() argument const?, Krzysztof Halasa, (Fri Jan 18, 4:44 pm)