Re: a few doubts!
- From: Mark McIntyre <markmcintyre@xxxxxxxxxxx>
- Date: Sat, 30 Apr 2005 17:14:36 +0100
On Sat, 30 Apr 2005 10:18:43 -0400, in comp.lang.c , Lew Pitcher
<lpitcher@xxxxxxxxxxxx> wrote:
>> char * a= "bcd";
>the array of 4 char cannot be altered
yes
>> strcpy(a,"hello");
so this is undefined behaviour.
>The more knowledgable ones around here will tell you whether this is "illegal
>behaviour" (because of the side-effect of strcpy(), which would be to attempt
>to overwrite a char constant) or just "undefined behaviour".
It is undefined. There's no syntax error here, so no reason to abort
compilation, if thats what you mean by 'illegal'.
>> a[0] = 't';
>
>IIUC, this should be illegal.
Its undefined behaviour.
>The compiler is non-compliant?
the warning levels are too low?
>The compiler is broken?
The compiler is operating perfectly, but isn't obligated to produce a
diagnostic for careless programming.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
.
- References:
- a few doubts!
- From: maadhuu
- Re: a few doubts!
- From: Lew Pitcher
- a few doubts!
- Prev by Date: Re: typedef struct
- Next by Date: Re: a few doubts!
- Previous by thread: Re: a few doubts!
- Next by thread: Re: a few doubts!
- Index(es):
Relevant Pages
|