This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: function parm attribute: must_assign


After upgrading to gcc-4.2.1 from a 3.4 version, I see that gcc now complains about uninitialized variables even when their address is passed to another function. Now that we get a warning about that variable being possibly initialized, I'm forced to add an instruction or two to initialize it (after I determine an appropriate value) or declare the function like this:

foo( __attribute__((must_assign)) long *ptr);
{
*ptr = _base_address_;
}

bar()
{
int *p;
foo( &p);

*p = ...
}
There's two things I really like about this:
1) In the caller, my warning goes away without having to determine an appropriate value in each caller of foo
2) In the callee, gcc can give a warning if there are any paths which leave that parm uninitialized.


If there's some other mechanism to achieve this functionality, I'd be interested in hearing about it. And if this is a new idea, I offer it to the gcc community.
John



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]