[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Suppressing GCC's "uninitialised" warnings

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2006-01-19 17:20:35 CET

Branko Čibej <brane@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
Received on Thu Jan 19 21:40:53 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.