[llvm] r186684 - Initialize TempFileHandle.

Serge Pavlov sepavloff at gmail.com
Fri Jul 19 20:27:33 PDT 2013


Using uninitialized variable causes undefined behavior. As discussion in
http://llvm.org/bugs/show_bug.cgi?id=16642 (Optimization eliminates an
overflow check) demonstartes, it may be dangerous, if compiler tries to
optimize. So the initialization was added for safety.

In regular build the warning is already turned off, I just experimented
with compilation out of the tree.

Thanks,
--Serge

2013/7/20 Rafael EspĂ­ndola <rafael.espindola at gmail.com>

> ah, ok.
>
> I wonder if we should disable this warning. We do it for gcc, no?
>
> On 19 July 2013 15:51, Serge Pavlov <sepavloff at gmail.com> wrote:
> > It removes complains of Visual Studio 2012. TempFileHandle is
> initialized in
> > one branch of switch statement (case FS_File). Then below in the code
> > TempFileHandle is used:
> >
> >   if (error_code ec = UTF16ToUTF8(random_path_utf16.begin(),
> >                                   random_path_utf16.size(),
> result_path)) {
> >     switch (Type) {
> >     case FS_File:
> >       ::CloseHandle(TempFileHandle);
> >
> >  It is again 'case FS_File' so TempFileHandle is initialized in fact, but
> > VS2012 compiler fais to reveal it.
> >
> >
> > 2013/7/20 Rafael EspĂ­ndola <rafael.espindola at gmail.com>
> >>
> >> > Initialize TempFileHandle.
> >>
> >> Why? Which code path was using it uninitialized?
> >>
> >> Cheers,
> >> Rafael
> >
> >
> >
> >
> > --
> > Thanks,
> > --Serge
>



-- 
Thanks,
--Serge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130720/93093637/attachment.html>


More information about the llvm-commits mailing list