Ok it's not really a bug; it's just a compiler warning.  I get this warning
when compiling the amalgamation:

 

gcc -Os -Wall -DFOSSIL_I18N=0 -L/mingw/lib -I/mingw/include  -I. -I./src
-DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0
-DSQLITE_DEFAULT_FILE_FORMAT=4 -Dlocaltime=fossil_localtime -c
./src/sqlite3.c -o sqlite3.o

./src/sqlite3.c: In function `getLastErrorMsg':

./src/sqlite3.c:28450: warning: dereferencing type-punned pointer will break
strict-aliasing rules

 

I think the change set below resolves the warning without introducing
another bug.  I could use a code review.

 

PS C:\rev\src\sqlite3\src> fossil info

project-name: SQLite

repository:   c:\rev\fossil\sqlite3.f

local-root:   C:/rev/src/sqlite3/

user-home:  : C:/Users/rev/AppData/Local

project-code: 2ab58778c2967968b94284e989e43dc11791f548

server-code:  2fa7c8b2762294d28396292f74c7b94c9c50af75

checkout:     a2b1183d9e9898d06d623b342bbb552e85a9b3f6 2010-01-11 12:00:48
UTC

parent:       14dc46a74aafe44c0bf7dffd26268395b2c5edb2 2010-01-09 07:33:54
UTC

tags:         trunk

PS C:\rev\src\sqlite3\src> fossil diff os_win.c

--- os_win.c

+++ os_win.c

@@ -1253,25 +1253,29 @@

   ** buffer, excluding the terminating null char.

   */

   DWORD error = GetLastError();

   DWORD dwLen = 0;

   char *zOut = 0;

+  union {

+    WCHAR** pzwc;

+    LPWSTR lpws;

+  } wu;

 

   if( isNT() ){

-    WCHAR *zTempWide = NULL;

+    *wu.pzwc = NULL;

     dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,

                            NULL,

                            error,

                            0,

-                           (LPWSTR) &zTempWide,

+                           wu.lpws,

                            0,

                            0);

     if( dwLen > 0 ){

       /* allocate a buffer and convert to UTF8 */

-      zOut = unicodeToUtf8(zTempWide);

+      zOut = unicodeToUtf8(*wu.pzwc);

       /* free the system buffer allocated by FormatMessage */

-      LocalFree(zTempWide);

+      LocalFree(*wu.pzwc);

     }

 /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.

 ** Since the ASCII version of these Windows API do not exist for WINCE,

 ** it's important to not reference them for WINCE builds.

 */

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to