[Bug middle-end/36550] Wrong may be used uninitialized warning (conditional PHIs)
--- Comment #9 from corinl at gmx dot de 2009-02-12 21:53 --- I do not really understand problem 5 for the case when the only dependancy for the code-path check is a local variable. In this case the value cannot be change by any other code than existing between the two checks, so this case should be handled reliable for sure. Of course this is not possible with global oder class variables which might be affected by some other thread. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36550
[Bug c++/39133] wrong optimization produces output of false warning
--- Comment #3 from corinl at gmx dot de 2009-02-12 07:26 --- Thanks for the info. Unluckily I just found the bug reported first now for sure: Code: // setuid/setgid only affect the current thread #define FS_PERMS_SET(_uid, _gid) \ bool check_permissions_local = check_permissions; \ uid_t fs_perms_uid_orig; \ gid_t fs_perms_gid_orig; \ if (check_permissions_local) \ { \ fs_perms_uid_orig = setfsuid(_uid); \ fs_perms_gid_orig = setfsgid(_gid); \ } // setuid/setgid only affect the current thread #define FS_PERMS_RESTORE() \ if (check_permissions_local) \ { \ setfsuid(fs_perms_uid_orig); \ setfsgid(fs_perms_gid_orig); \ } #define FOP_ERRNO(R) out-op_errno=((R==0)?0:errno) ... line 934: FS_PERMS_SET(in-uid, in-gid); FOP_ERRNO(statvfs(path, out-stbuf)); FS_PERMS_RESTORE(); ... Error report: main.cpp:934: Warnung: »fs_perms_gid_orig« könnte in dieser Funktion uninitialisiert verwendet werden main.cpp:934: Warnung: »fs_perms_uid_orig« könnte in dieser Funktion uninitialisiert verwendet werden This is not true, as at this point the variables are only written to. They are only ever read (and even later) if they have first been written to. -- corinl at gmx dot de changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|FIXED | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39133
[Bug c++/39133] wrong optimization produces output of false warning
--- Comment #4 from corinl at gmx dot de 2009-02-12 07:37 --- here's the copy from the precompiled header file (.ii), may be it helps: (check_permissions_local removed, it was just for test..same error as before) uid_t fs_perms_uid_orig; gid_t fs_perms_gid_orig; if (check_permissions) { fs_perms_uid_orig = setfsuid(in-uid); fs_perms_gid_orig = setfsgid(in-gid); }; out-op_errno=((statvfs(path, out-stbuf)==0)?0:(*__errno_location ())); if (check_permissions) { setfsuid(fs_perms_uid_orig); setfsgid(fs_perms_gid_orig); }; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39133
[Bug c++/39133] New: wrong optimization produces output of false warning
piece of code inside contained in class methode (starting line 263): --- char *buf; if (!strncmp(in-loc.path,/translators/,strlen(/translators/))) { translator_c *xl = translator_from_path(in-loc.path); if (xl) { char *loc = in-loc.path+strlen(/translators/)+strlen(xl-name); LOG_DEBUG(log, control_get_data, xl '%s', loc '%s', xl-name, loc); buf = xl-control_get_data(loc); } } else { char *loc = in-loc.path; LOG_DEBUG(log, control_get_data, internal, loc '%s', loc); buf = control_get_data(loc); } if (buf) { MEM_NEW(persistent, persistent_c()); persistent-read_mode = true; persistent-data = buf; persistent-data_len = strlen(persistent-data); out-ref = (xl_ref_t) persistent; out-op_errno = 0; } else { out-op_errno = ENOENT; } --- compiling with the following options works fine (no warnings, no errors): --- CFLAGS=-Wall -Werror -fPIC -pthread -I../common -I../../common -I../../../common -I../shared -I../../shared -I../../../shared -O0 -g --- compiling with the following options produces a warning (=error); --- CFLAGS=-Wall -Werror -fPIC -pthread -I../common -I../../common -I../../../common -I../shared -I../../shared -I../../../shared -O3 -ffast-math --- cc1plus: warnings being treated as errors main.cpp: In member function »virtual void main_c::fop_open(stack_frame_t*)«: main.cpp:263: Warnung: »buf« könnte in dieser Funktion uninitialisiert verwendet werden make: *** [main.o] Fehler 1 --- Fehler = Error »buf« könnte in dieser Funktion uninitialisiert verwendet werden = buf could be used uninitialized in this function --- as you can clearly see, buf could never be used uninitialized so this must be a compiler/optimizer bug. -- Summary: wrong optimization produces output of false warning Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: corinl at gmx dot de GCC build triplet: 4.2.3-2ubuntu7 GCC host triplet: x86_64 GCC target triplet: x86_64 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39133
[Bug c++/39133] wrong optimization produces output of false warning
--- Comment #1 from corinl at gmx dot de 2009-02-08 22:07 --- Oh sorry, I just see that buf could be used uninitialized for sure (if xl==NULL). but well, shouldn't this warning then be issued all the times? so the bug is now reversed - missing warning instead of false warning ;) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39133