This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gcc-in-cxx] Don't initialize variable to itself
On Wed, Mar 4, 2009 at 5:43 PM, Ian Lance Taylor <iant@google.com> wrote:
> Andrew Pinski <pinskia@gmail.com> writes:
>
>> On Wed, Mar 4, 2009 at 8:31 AM, Ian Lance Taylor <iant@google.com> wrote:
>>> I committed this patch to the gcc-in-cxx branch to avoid initializing a
>>> variable to itself. ?This avoids a warning from the C++ frontend.
>>
>> int a = a; should really disable the unitialized warning even in the
>> C++ front-end. ?If it is not then it is a bug.
>
> It's not an uninitialized warning. ?It's
> ? warning: operation on 'alloc' may be undefined
> It's being generated by -Wsequence-point.
>
> I haven't looked into why the C++ frontend generates the warning when
> the C frontend doesn't.
The C++ FE is probably confused here. But the patch looks like it
just fixes a cut&paste error. At least I cannot see that the alloc = alloc
part would be to silence an uninitialized use warning as there clearly
is an initialization from the function call.
- unsigned alloc = alloc = calculate_allocation (pfx, reserve, exact);
+ unsigned alloc = calculate_allocation (pfx, reserve, exact);
Richard.
> Ian
>