From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: "Thomas Bushnell, BSG" Message-ID: <87vgbxhf95.fsf@becket.becket.net> Content-Type: text/plain; charset=us-ascii References: <4da3d9af.0203131248.60d6899e@posting.google.com>, <3C914E64.D5D00447@null.net>, <4da3d9af.0203150929.1d3154d2@posting.google.com> Subject: Re: macro fun [Re: [9fans] plan or side effect] Date: Mon, 18 Mar 2002 10:32:39 +0000 Topicbox-Message-UUID: 6888b856-eaca-11e9-9e20-41e7f4b1d025 "ozan s. yigit" writes: > this is absolute crap. here is t.c. so obvious, i'm surprised > you of all people had to comment. > > #include > #include > > extern char *strcpy(char *, const char *); > > int main(int argc, char **argv) { > char buf[10]; > strcpy(buf, "hello boyd!"); > printf("%s\n", buf); > return 0; > } This is not standard conformant. "If a program declares or defines an identifier with the same name as an identifier reserved in that context...the behavior is undefined." (ANSI C, 4.1.2.1) The "strcpy" identifier is reserved in external contexts by section 4.11.2.3. Posix guarantees you that "redeclarations" like yours are safe, but that's only for the identifiers Posix specifies. ANSI C's identifiers come with so such guarantee, intentionally. GCC does not attempt to catch such errors, nor is it required to. Thomas