This is the mail archive of the gcc-patches@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]

Re: PATCH RFA: Add new warning for jump across initialized variable


On Fri, Jun 19, 2009 at 9:20 PM, Andrew Pinski<pinskia@gmail.com> wrote:
> On Fri, Jun 19, 2009 at 9:07 PM, H.J. Lu<hjl.tools@gmail.com> wrote:
>> On Mon, Jun 15, 2009 at 10:13 PM, Ian Lance Taylor<iant@google.com> wrote:
>>> "Joseph S. Myers" <joseph@codesourcery.com> writes:
>>>
>>>> On Wed, 10 Jun 2009, Ian Lance Taylor wrote:
>>>>
>>>>> This patch adds a new warning to the C frontend: -Wgoto-misses-init.
>>>>> This warns about cases where a goto, or a switch, branches across the
>>>>> initialization of a variable. ?For example:
>>>>
>>>> Since this covers switch statements, I think an option name only
>>>> mentioning goto is bad; -Wjump-misses-init or -Wjump-across-init would be
>>>> better. ?OK with that change and otherwise fixed as indicated below.
>>>
>>> Thanks. ?Fixed, updated, rebootstrapped, retested, and committed. ?I use
>>> -Wjump-misses-init because in a case like
>>>
>>> ?goto a:
>>> ?{
>>> ? ?int a = 0;
>>> ? b:
>>> ?}
>>> ?a:
>>> ?goto b;
>>>
>>> the initialization is missed, but not crossed.
>>>
>>
>> This breaks binutils build:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40500
>
>
> And this is expected behavior as the warning is doing what it is
> supposed to be doing.

If it is case, this warning is almost next to useless since
the uninitialized value doesn't change the code behavior.


-- 
H.J.


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