You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Philip Martin <ph...@codematters.co.uk> on 2006/01/19 16:20:35 UTC

Re: Suppressing GCC's "uninitialised" warnings

Branko Čibej <br...@xbc.nu> writes:

> and b) surely a future version of GCC will do better in this
> case, especially if someone reports the bug to them (hint, hint!)

"Do better" probably requires GCC to do whole program optimisation.
Humans can determine that the warnings are "wrong" only by using the
knowledge that svn_error_create will never return NULL.  GCC doesn't
emit the warnings if it has the same information, but generally the
definition of svn_error_create isn't even in the same library, let
alone the same translation unit:

$ gcc -Wall -O2 -c z.c
z.c: In function 'bar':
z.c:9: warning: 'i' is used uninitialized in this function

$ gcc -Wall -O2 -c -DVISIBLE z.c

$ cat z.c
typedef struct svn_error_t { int i; } svn_error_t;
extern svn_error_t *svn_error_create(void);
static svn_error_t *foo(int *p) { return svn_error_create(); }
svn_error_t *bar(void)
{
  int i;
  svn_error_t *err = foo(&i);
  if (err) return err;
  if (i) return svn_error_create();
  return 0;
}
#ifdef VISIBLE
svn_error_t *svn_error_create(void) { static svn_error_t d; return &d; }
#endif

I'm not exactly sure what constitues the GCC "bug" beyond the fact
that the warning is a false alarm, and false alarms are why there is a
-Wno-initialized flag.  I suppose we could ask for a way to label the
function declaration, __attribute__(nonullreturn) perhaps?

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org