Craig A. Berry
2013-10-10 22:47:43 UTC
The compiler I'm using (HP C V7.3-020 on OpenVMS IA64 V8.4) doesn't like the fact that we now (as of branch-0_92-611-g7dc0487) try to do arithmetic on a pointer to void:
CC/DECC /DEFINE=(TDS50,"_THREAD_SAFE"=1)/PREFIX=(ALL)/FLOAT=IEEE/IEEE=DENORM/OBJECT=[.SRC.TDS]STREAM.OBJ /NAMES=SHORTENED /DEBUG/NOOPTIMIZE/LIST=[.S
RC.TDS]STREAM/SHOW=(EXPANSION,INCLUDE)/INCLUDE=("./","./include") [.SRC.TDS]STREAM.C
stream->buffer += len;
........^
%CC-W-BADPTRARITH, In this statement, performing pointer arithmetic on a pointer to void or a pointer to function is not allowed. The compiler will treat the type as if it were pointer to char.
at line number 175 in file D0:[craig.freetds-0^.92^.dev^.20131003.src.tds]stream.c;1
According to the Stack Overflow article at <http://stackoverflow.com/questions/3523145/pointer-arithmetic-for-void-pointer-in-c>, MSVC would have the same problem and the consensus there is that this does in fact violate the C99 standard.
Since the compiler is going to treat it like pointer to char anyway, and since what we have now is dubious from a sC standards viewpoint, wouldn't it be better to just make it a pointer to char in the first place, like so:
--- include/freetds/stream.h;-0 2013-10-03 15:19:49 -0500
+++ include/freetds/stream.h 2013-10-03 21:30:57 -0500
@@ -45,7 +45,7 @@ typedef struct tds_output_stream {
* client should not cache buffer and buf_len before a call
* to write as write can change these values.
*/
- void *buffer;
+ char *buffer;
size_t buf_len;
} TDSOUTSTREAM;
[end]
________________________________________
Craig A. Berry
mailto:craigberry at mac.com
"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser
CC/DECC /DEFINE=(TDS50,"_THREAD_SAFE"=1)/PREFIX=(ALL)/FLOAT=IEEE/IEEE=DENORM/OBJECT=[.SRC.TDS]STREAM.OBJ /NAMES=SHORTENED /DEBUG/NOOPTIMIZE/LIST=[.S
RC.TDS]STREAM/SHOW=(EXPANSION,INCLUDE)/INCLUDE=("./","./include") [.SRC.TDS]STREAM.C
stream->buffer += len;
........^
%CC-W-BADPTRARITH, In this statement, performing pointer arithmetic on a pointer to void or a pointer to function is not allowed. The compiler will treat the type as if it were pointer to char.
at line number 175 in file D0:[craig.freetds-0^.92^.dev^.20131003.src.tds]stream.c;1
According to the Stack Overflow article at <http://stackoverflow.com/questions/3523145/pointer-arithmetic-for-void-pointer-in-c>, MSVC would have the same problem and the consensus there is that this does in fact violate the C99 standard.
Since the compiler is going to treat it like pointer to char anyway, and since what we have now is dubious from a sC standards viewpoint, wouldn't it be better to just make it a pointer to char in the first place, like so:
--- include/freetds/stream.h;-0 2013-10-03 15:19:49 -0500
+++ include/freetds/stream.h 2013-10-03 21:30:57 -0500
@@ -45,7 +45,7 @@ typedef struct tds_output_stream {
* client should not cache buffer and buf_len before a call
* to write as write can change these values.
*/
- void *buffer;
+ char *buffer;
size_t buf_len;
} TDSOUTSTREAM;
[end]
________________________________________
Craig A. Berry
mailto:craigberry at mac.com
"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser