freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Craig A. Berry" <craigberry AT mac.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: [freetds] pointer arithmetic on a pointer to void
- Date: Thu, 10 Oct 2013 17:47:43 -0500
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
-
[freetds] pointer arithmetic on a pointer to void,
Craig A. Berry, 10/10/2013
-
Re: [freetds] pointer arithmetic on a pointer to void,
James K. Lowden, 10/10/2013
-
Re: [freetds] pointer arithmetic on a pointer to void,
Craig A. Berry, 10/11/2013
- Re: [freetds] pointer arithmetic on a pointer to void, Frediano Ziglio, 10/12/2013
-
Re: [freetds] pointer arithmetic on a pointer to void,
Craig A. Berry, 10/11/2013
-
Re: [freetds] pointer arithmetic on a pointer to void,
James K. Lowden, 10/10/2013
Archive powered by MHonArc 2.6.24.