Article View: comp.std.c
Article #6193incompatibility of character pointers
From: Bruce Blodgett
Date: Tue, 06 Feb 1990 16:39
Date: Tue, 06 Feb 1990 16:39
28 lines
1510 bytes
1510 bytes
As far as I can tell, the following code fragment is not legal ANSI C:
{
char * cp;
unsigned char * ucp;
signed char * scp;
cp = "abc"; /* ok - string literal (array of char) becomes pointer to char */
ucp = "def"; /* pointer to unsigned char INCOMPATIBLE with pointer to char */
scp = "ghi"; /* pointer to signed char INCOMPATIBLE with pointer to char */
}
Constraint from simple assignment section 3.3.16.1:
"One of the following shall hold:
... both operands are pointers to ... compatible types"
Now consider the types being pointed to (unsigned char vs char vs signed char).
From compatible type section 3.1.2.6:
"Two types have compatible type if their types are the same. Additional rules
for determining whether two types are compatible are described in section
3.5.2 for type specifiers"
From type specifier section 3.5.2:
"Each list of type specifiers shall be one of the following sets"
Since char, signed char, and unsigned char form three distinct lists, they
are not the same type. Consequently, pointers to them are NOT compatible
types. Am I wrong?
Bruce Blodgett
Technical Details
Message-ID:
<1990Feb6.163933.11022@granite.cr.bull.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!rex!uflorida!mephisto!bbn!granite!blodgettShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!rex!uflorida!mephisto!bbn!granite!blodgett From: blodgett@granite.cr.bull.com (Bruce Blodgett) Newsgroups: comp.std.c Subject: incompatibility of character pointers Message-ID: <1990Feb6.163933.11022@granite.cr.bull.com> Date: 6 Feb 90 16:39:33 GMT Organization: Bull HN Information Systems Inc. Lines: 28