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

Reply via email to