public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/21513] New: Obsolete uninizialized Warning message
@ 2005-05-11 13:53 alexander_herrmann at yahoo dot com dot au
  2005-05-11 14:06 ` [Bug tree-optimization/21513] [4.0/4.1 Regression] __builtin_expect getting in the way of uninitialized warnings pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: alexander_herrmann at yahoo dot com dot au @ 2005-05-11 13:53 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-09-05 19:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-21513-10614@http.gcc.gnu.org/bugzilla/>
2005-10-13  1:48 ` [Bug tree-optimization/21513] [4.0/4.1 Regression] __builtin_expect getting in the way of uninitialized warnings pinskia at gcc dot gnu dot org
2005-10-31  3:31 ` mmitchel at gcc dot gnu dot org
2005-11-01 10:46 ` alexander_herrmann at yahoo dot com dot au
2005-12-17 10:27 ` [Bug tree-optimization/21513] [4.0/4.1/4.2 " bonzini at gnu dot org
2006-02-27 14:01 ` steven at gcc dot gnu dot org
2006-03-03 17:58 ` pinskia at gcc dot gnu dot org
2006-10-23 21:30 ` pinskia at gcc dot gnu dot org
2007-09-05 19:54 ` nemet at gcc dot gnu dot org
2005-05-11 13:53 [Bug c/21513] New: Obsolete uninizialized Warning message alexander_herrmann at yahoo dot com dot au
2005-05-11 14:06 ` [Bug tree-optimization/21513] [4.0/4.1 Regression] __builtin_expect getting in the way of uninitialized warnings pinskia at gcc dot gnu dot org
2005-05-28 18:00 ` pinskia at gcc dot gnu dot org
2005-08-22 12:26 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).