Skip to Content.
Sympa Menu

freetds - [freetds] tdsstring.c ansi alias problem

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Craig A. Berry" <craigberry AT mac.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] tdsstring.c ansi alias problem
  • Date: Sun, 4 May 2003 22:26:27 -0500

My compiler (Compaq C V6.5-001 on OpenVMS Alpha V7.3-1) doesn't like the
following snippet of src/tds/tdsstring.c:


*(char **) s = src;
........^
%CC-W-BADANSIALIAS, This statement uses the type "pointer to char" to
reference the same storage location as the statement at line number 113 in
file D0:[CRAIG.FREETDS-0_62_DEV_20030503.SRC.TDS]TDSSTRING.C;1, which uses
the type "pointer to struct DSTR_CHAR". This does not conform to the ANSI
aliasing rules.
at line number 112 in file
D0:[CRAIG.FREETDS-0_62_DEV_20030503.SRC.TDS]TDSSTRING.C;1

The complete function where this occurs is:


DSTR
tds_dstr_set(DSTR * s, char *src)
{
if (*(char **) s != tds_str_empty)
free(*(char **) s);
*(char **) s = src;
return *s;
}


I guess I don't understand the purpose of casting the left-hand side of
"*(char **) s = src;" rather than the right, or why it's cast as a double
pointer and then dereferenced rather than just being cast as a single
pointer. My confusion wouldn't really be relevant except that it prevents
me from knowing what to do about this. I can suppress ANSI aliasing by
adding the appropriate compiler flag, but I don't know how hot this bit of
code is or whether the optimizations allowed by aliasing would make any real
difference.
--
________________________________________
Craig A. Berry
mailto:craigberry AT mac.com

"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser




Archive powered by MHonArc 2.6.24.

Top of Page