From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15997 invoked by alias); 10 May 2007 10:01:09 -0000 Received: (qmail 15893 invoked by uid 48); 10 May 2007 10:00:45 -0000 Date: Thu, 10 May 2007 10:01:00 -0000 Subject: [Bug c/31893] New: Please provide an "inout" attribute for function parameters. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "madcoder at debian dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-05/txt/msg00768.txt.bz2 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