public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31893]  New: Please provide an "inout" attribute for function parameters.
@ 2007-05-10 10:01 madcoder at debian dot org
  2007-05-10 10:13 ` [Bug c/31893] " madcoder at debian dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: madcoder at debian dot org @ 2007-05-10 10:01 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <bug-31893-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2015-06-10 13:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-10 10:01 [Bug c/31893] New: Please provide an "inout" attribute for function parameters madcoder at debian dot org
2007-05-10 10:13 ` [Bug c/31893] " madcoder at debian dot org
2007-05-10 22:01 ` pinskia at gcc dot gnu dot org
2007-05-11  8:33 ` madcoder at debian dot org
2008-08-18 16:51 ` manu at gcc dot gnu dot org
2008-08-18 17:15 ` manu at gcc dot gnu dot org
     [not found] <bug-31893-4@http.gcc.gnu.org/bugzilla/>
2012-03-16 23:26 ` manu at gcc dot gnu.org
2013-08-28  8:25 ` rguenth at gcc dot gnu.org
2015-06-10 10:39 ` bugzilla@poradnik-webmastera.com
2015-06-10 13:45 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).