This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/31893] New: Please provide an "inout" attribute for function parameters.
- From: "madcoder at debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 May 2007 10:00:45 -0000
- Subject: [Bug c/31893] New: Please provide an "inout" attribute for function parameters.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Here is what I mean. When you write code like:
int foo(void) {
static bar_t bar;
call_some_function(&bar);
return 0;
}
gcc assumes that call_some_function will initialize bar properly. Though,
sometimes call_some_function is a function that will modify 'bar' but also need
it to be properly initialized. In that case, the parameter is inout. (I must
say I'm unsure what gcc thinks if call_some_function prototype is: void
call_some_function(const bar_t *); maybe it suffers from the same problem).
That'd be great to have an __attribute__((inout(1,2,3...))) to say that the
1st, 2nd, 3rd, ... variables of the function need their argument to be
initialized. That would make gcc issue warning about variables beeing used
uninitialized properly.
Maybe "inout" is a very lousy name, and I don't care much about it. My point
is, I'd really like to be able to express in the function prototypes that a
structure needs to be initialized before that function can be called. WIth this
attribute, the call_some_function prototype would be:
int call_some_function(bar_t *) __attribute__((inout(1)));
--
Summary: Please provide an "inout" attribute for function
parameters.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: madcoder at debian dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31893