On 1/27/17 6:06 PM, Keith Medcalf wrote:

On Friday, 27 January, 2017 08:26, Clemens Ladisch <clem...@ladisch.de> said:

David Empson wrote:
Perhaps SQLite’s test procedure should be enforcing strict ANSI C mode?
If this is already being done, then the compiler(s) used might not be
enforcing this particular rule.
"gcc -pedantic -std=c90" (or gnu90) would check for this error:

test.c:6:3: warning: initializer element is not computable at load time [-
Wpedantic]
But the error message/warning is of high bogosity.

While it is true that the initializer element cannot be computed at "load" time, it is not a "load time" item 
that is being initialized.  The item being initialized is a dynamic element on the stack inside a function call and it is 
initialized from a function argument.  It is entirely irrelevant that the element cannot be computed at "load time" 
because computing it thusly would be of no use whatsoever -- initialization of items residing on a functions call stack must 
always be done at "run time" and can never be done at "load time".

So the erroneous warning should just be ignored and a bug report filed against 
the compiler.

except that the C90 standard apparently says that aggregates (like this), need to be initialized to a constant (load time), possibly to allow the function to initialize the variable with a memcpy (or equivalent) from a constant initialization buffer. C99 apparently decided that rather than making the programmer make the transformation to update a few 'call time' values, it was better to make the compiler do that work (as it would be less error prone).

--
Richard Damon

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

Reply via email to