[llvm-commits] [PATCH] Don't cast Win32 FILETIME structs to int64

NAKAMURA Takumi geek4civic at gmail.com
Sat Aug 28 02:54:25 PDT 2010


This looks fine for me.
Confirmed on mingw.


Thank you, ...Takumi


2010/8/6 Dimitry Andric <dimitry at andric.com>:
> Subject: Don't cast Win32 FILETIME structs to int64
>
> According to the Microsoft documentation here:
> http://msdn.microsoft.com/en-us/library/ms724284%28VS.85%29.aspx
>
> this cast used in lib/System/Win32/Path.inc:
>
> __int64 ft = *reinterpret_cast<__int64*>(&fi.ftLastWriteTime);
>
> should not be done.  The documentation says: "Do not cast a pointer to a
> FILETIME structure to either a ULARGE_INTEGER* or __int64* value because
> it can cause alignment faults on 64-bit Windows."
>
> When compiling with MinGW gcc 4.5.0, you also get some strict-aliasing
> warnings about those casts:
>
> In file included from lib/System/Path.cpp:262:0:
> lib/System/Win32/Path.inc: In member function 'const llvm::sys::FileStatus* llvm::sys::PathWithStatus::getFileStatus(bool, std::string*) const':
> lib/System/Win32/Path.inc:403:65: warning: dereferencing type-punned pointer will break strict-aliasing rules
> lib/System/Win32/Path.inc: In member function 'bool llvm::sys::Path::setStatusInfoOnDisk(const llvm::sys::FileStatus&, std::string*) const':
> lib/System/Win32/Path.inc:781:14: warning: dereferencing type-punned pointer will break strict-aliasing rules
>
> Attached is a fix that uses the recommended ULARGE_INTEGER structure,
> and fixes the strict-aliasing warnings as a side-effect.  Please review.
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>




More information about the llvm-commits mailing list