On 06/01/2014 09:34 AM, Ben Walton wrote: > * Avoid possible compiler warnings/errors by defining the out label > only when it may be accessed. > > Signed-off-by: Ben Walton <bdwal...@gmail.com> > --- > > Hi All, > > When building coreutils 8.22 on Solaris with -Werror=unused-label, the build > fails with: > > lib/rename.c: In function 'rpl_rename': > lib/rename.c:465:2: error: label 'out' defined but not used > [-Werror=unused-label] > out: > ^
Are you building from a git checkout repo? Otherwise you should have to configure --enable-gcc-warnings to get -Werror enabled? > I think this should make the compiler happier. Feel free to suggest better > solutions though. I'm not sure this is the best way to handle it. > > lib/rename.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/lib/rename.c b/lib/rename.c > index 2116028..9c507c2 100644 > --- a/lib/rename.c > +++ b/lib/rename.c > @@ -462,7 +462,14 @@ rpl_rename (char const *src, char const *dst) > > ret_val = rename (src_temp, dst_temp); > rename_errno = errno; > + > +# if (RENAME_TRAILING_SLASH_SOURCE_BUG || RENAME_DEST_EXISTS_BUG \ > + || RENAME_HARD_LINK_BUG) > + /* Avoid compiler warnings about unused labels. Only > + create this label if it will be used. */ > out: > +# endif > + Note one can mark a label as possibly unused like: out: _GL_UNUSED; That's supported on all gcc, and newer g++ since https://gcc.gnu.org/ml/gcc-patches/2009-05/msg01897.html So to support compiling with older g++ one could: out: #if (!defined __cplusplus) || __GNUC__ >= ? || (__GNUC__ == ? && __GNUC_MINOR__ >= ?) _GL_UNUSED; #endif With the ?s filled in as appropriate. thanks, Pádraig.