On Tue, Sep 29, 2009 at 05:28:39PM -0700, Roger Binns wrote:
> Nicolas Williams wrote:
> > On Tue, Sep 29, 2009 at 11:21:30AM -0700, Roger Binns wrote:
> >> Nicolas Williams wrote:
> >>> If you move the cast to the left the warning should go away: 
> >>> ((sqlite3_int64)(1L<<63))
> >> And this is why making warnings go away leads to bugs.  The replacement
> >> above will only work if sizeof(long)==sizeof(long long) which is not the
> >> case on Windows in 64 bit mode or in 32 bit mode in general on any 
> >> platform.
> > 
> > Where is long long entering the picture here? 
> 
> Really? The cast is to a 64 bit quantity.  Pretty much every compiler uses
> 'long long' to represent a 64 bit quantity (even in 32 bit mode), although
> some also have __int64 and others int64_t depending on age and standards
> compliance.

Oh, I think you meant that the L suffix would break on anything other
than LP64 or ILP64 models.  I'm not entirely sure of the use of the L
suffix, and perhaps that would be a problem.  If you can't find a
constant that works equally well in ILP32 and LP64 then you can use
#ifdefs.  But I think that it is possible to have such a constant
without causing compiler warnings (for one, you can have the literal
constant, in decimal).

> Another example of compilers whining is gcc saying that in one part of the
> code, a parameter to memset could be zero (which usually indicates a
> programming error).  Except the compiler is wrong as human inspection
> proves.  Just because a warning is present does not mean it is right or that
> the compiler is perfect.  Hiding these warnings is even more dangerous
> because it obfuscates the original intention of the code.  (This is why a
> universal no warnings policy can hurt.)

Indeed, and I've expressed agreement on that.

> Demonstrate the code is wrong functionality (ie tests are broken) or that it
> isn't written in a standards compliant way :-)  The compiler warnings could
> help point to those locations.

In this case, there's no problem with ignoring this warning.

Nico
-- 
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to