Because of my used compiler flags -Werreor it is stated as error insteed of a
warning. The problem is that the compiler complains while there isn't anythin
wrong at all. Worked with 3.4.3. aie_memory_heap_ptr is the variable which the
compiler wrong assumes that it may not be initialized while it is either
initialized or not used within the scope. It may not be a feature :)

Configured with: ../gcc-3.4.3/configure --enable-languages=c,c++,java
--enable-shared --enable-threads=posix --with-cpu=i686 --with-system-zlib
Thread model: posix

Error:
src/aie_memutil.c: In Funktion _aie_malloc:
src/aie_memutil.c:154: Warnung: aie_memory_heap_ptr k๖nnte in dieser 
Funktion
uninitialisiert verwendet werden
make[1]: *** [obj/aie_memutil.o] Fehler 1
make[1]: Leaving directory `/aIEngine/src/aiengine'
make: *** [install] Fehler 1

aie_memory_heap could be unitilized in this function. It can but if not it's not
used. Difference to GCC 3.4.3.
The function is my own memory allocation setting a overwrite protection for the
allocated memory (post and pre headers) - it is as follows:

void *_aie_malloc(unsigned int size, const char *file, unsigned int line)
{
   void *rc_ptr = NULL;
   struct aie_memory_heap *aie_memory_heap_ptr;
   if (__builtin_expect(((size != 0) &&
       (aie_memory_heap_ptr = (struct aie_memory_heap *)
                        malloc(sizeof(struct aie_memory_heap))) != NULL),true))
   {
      register unsigned int real_size = 
                      size + sizeof(aie_memory_start) + sizeof(aie_memory_end);
      //aie_memory_heap_ptr->file = strdup(file);
      if ((aie_memory_heap_ptr->file = 
                                     (char *)malloc(strlen(file) + 1)) != NULL)
      {
         strcpy(aie_memory_heap_ptr->file, file);
      }
      aie_memory_heap_ptr->line = line;
      aie_memory_heap_ptr->size = size;
      aie_memory_heap_ptr->prev = NULL;
      if (__builtin_expect(
               ((aie_memory_heap_ptr->next = aie_memory_heap_base) 
                                                          != NULL),true))
      {
         aie_memory_heap_base->prev = aie_memory_heap_ptr;
      }
      if (__builtin_expect(
               ((aie_memory_heap_ptr->ptr = 
                 (void *)malloc(real_size)) == NULL),false))
      {
         sys_log("%s(%d): Out of Memory?! @ %s(%d)", __FILE__, __LINE__, 
                                                                   file, line);
      }
      else
      {
         memcpy(aie_memory_heap_ptr->ptr, aie_memory_start, 
                                                     sizeof(aie_memory_start));
         memcpy((char *)aie_memory_heap_ptr->ptr +
               (real_size - sizeof(aie_memory_end)), aie_memory_end, 
                                                     sizeof(aie_memory_end));
         *(char *)(rc_ptr = (char *)aie_memory_heap_ptr->ptr + 
                                              sizeof(aie_memory_start)) = '\0';
      }
      aie_memory_heap_base = aie_memory_heap_ptr;
      if ((aie_akt_mem_usage += size) > aie_max_mem_usage)
      {
         aie_max_mem_usage = aie_akt_mem_usage;
      }
   }
   else
   {
      sys_log("%s(%d): No Memory - Size[%d]?!", __FILE__, __LINE__, size);
   }
   return(rc_ptr);
}

Solution: Waste a byte and maybe a CPU cycle and initilize aie_memory_heap_ptr
it when defined.

-- 
           Summary: Obsolete uninizialized Warning message
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexander_herrmann at yahoo dot com dot au
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21513

Reply via email to