delorie.com/archives/browse.cgi | search |
From: | Martin Stromberg <eplmst AT epl DOT ericsson DOT se> |
Message-Id: | <200205261623.SAA08354@lws256.lu.erisoft.se> |
Subject: | Re: refresh++ |
To: | djgpp-workers AT delorie DOT com |
Date: | Sun, 26 May 2002 18:23:45 +0200 (MET DST) |
In-Reply-To: | <3CF107A3.4651AF3D@phekda.freeserve.co.uk> from "Richard Dawe" at May 26, 2002 05:04:51 PM |
X-Mailer: | ELM [version 2.5 PL3] |
MIME-Version: | 1.0 |
Reply-To: | djgpp-workers AT delorie DOT com |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp-workers AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
Richard said: > Martin Str|mberg wrote: > [snip] > > Yes. Why (extremely strong expletive) is gcc complaining about > > perfectly legal and useful code. > > It's actually trying to help us out. The warning is about the "zero-length > format string" we're passing to snprintf. It's only an error, because we're > compiling with -Werror now. Sure it's trying to help us. But what's wrong with an empty format string if all we want is a zero length string? It's insane. Can anybody understand why this would be helpful? > IMHO using snprintf like this to truncate a string is overkill. Why not just > truncate it using "buf[0] = '\0';"? Yes. So what? Consider some kind of general automatically generated format strings. Now that isn't possible because gcc thinks it's a possible error worthy of a warning. And I suspect it isn't only snprintf() that have this problem. Aren't all *printf() functions generating this warning? Perhaps it is sane complaining about this for snprintf(). As I've never used that function so far I don't have a good sense of what's sane for that function. If this applies only to snprintf(), perhaps it's ok (I must defer to others who is more acquainted to that function). But if this applies to all *printf() functions (because I can see places where it's useful), it's insane. Right, MartinS
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |