Why does GCC allow '$' character in variable and function names?

2006-10-17 Thread Sajish V
I think that C does not allow special characters ( '~' '!' '@' '#' '$' '%' '^' 
'&' '*' ) in variable and function names. My knowledge is purely based on the 
books that I have been reading to learn C.

To verify this when I tried to compile a C program using GCC with '$' in 
variable names and function names I found that GCC does not complain. No errors 
or warnings. 

I used the basic command with no option to compile. 

bash$ gcc 

Can someone please let me know why GCC allows '$' character in variable and 
function names?

Thanks.




free (static_array)

2008-06-30 Thread Sajish V
Hi All, 
Can you please let me know why GCC does not crib when we try to free a static 
array?
main ()
{ 
 char array[100];
 free (array);
}
The above code compiles without any hitch. 
Thanks,
Sajish.





Re: free (static_array)

2008-07-01 Thread Sajish V
Thanks for the reply, Denys.
My question was, why doesn't gcc catch it during compilation? It is clear that 
we are trying to free a variable from stack. Shouldn't gcc flag an error for 
this during compilation?
Regards,
Sajish.



- Original Message 
From: Denys Vlasenko <[EMAIL PROTECTED]>
To: gcc@gcc.gnu.org
Cc: Sajish V <[EMAIL PROTECTED]>
Sent: Tuesday, July 1, 2008 2:44:06 PM
Subject: Re: free (static_array)

On Tuesday 01 July 2008 08:38, Sajish V wrote:
> Hi All, 
> Can you please let me know why GCC does not crib when we try to free a static 
> array?
> main ()
> { 
>  char array[100];
>  free (array);
> }
> The above code compiles without any hitch. 
> Thanks,
> Sajish.

# ./a.out
*** glibc detected *** ./a.out: free(): invalid pointer: 0xffa8b530 ***
=== Backtrace: =
/lib/libc.so.6[0xf7ecb7a7]
/lib/libc.so.6(__libc_free+0x79)[0xf7ecc0ad]
./a.out[0x804834e]
/lib/libc.so.6(__libc_start_main+0x138)[0xf7e8da74]
./a.out[0x80482b5]
=== Memory map: 
08048000-08049000 r-xp  08:06 1315925
/.local/tmp/a.out
08049000-0804a000 rwxp  08:06 1315925
/.local/tmp/a.out
0804a000-0806b000 rwxp 0804a000 00:00 0  [heap]
f7e6f000-f7e76000 r-xp  08:05 46193  
/app/gcc-3.3.3/lib/libgcc_s.so.1
f7e76000-f7e77000 rwxp 6000 08:05 46193  
/app/gcc-3.3.3/lib/libgcc_s.so.1
f7e77000-f7e78000 rwxp f7e77000 00:00 0
f7e78000-f7f6 r-xp  08:0

--
vda



  


Re: free (static_array)

2008-07-08 Thread Sajish V
Thanks everyone!
I will file a feature request for this via bugzilla.

Regards,
Sajish.



- Original Message 
From: Joseph S. Myers <[EMAIL PROTECTED]>
To: Michael Meissner <[EMAIL PROTECTED]>
Cc: Denys Vlasenko <[EMAIL PROTECTED]>; Sajish V <[EMAIL PROTECTED]>; 
gcc@gcc.gnu.org
Sent: Tuesday, July 1, 2008 5:07:05 PM
Subject: Re: free (static_array)

On Tue, 1 Jul 2008, Michael Meissner wrote:

> On Tue, Jul 01, 2008 at 11:50:58AM +0200, Denys Vlasenko wrote:
> > On Tuesday 01 July 2008 09:24, Sajish V wrote:
> > > Thanks for the reply, Denys.
> > > My question was, why doesn't gcc catch it during compilation? It is clear
> > > that we are trying to free a variable from stack. Shouldn't gcc flag an
> > > error for this during compilation?
> 
> It could.  Nobody has written the code to do so, and as they say patches are
> welcome (assuming you have done the paperwork to legally contribute to GCC).
> Have you filed a feature request via bugzilla so that it can be tracked?

An error is inappropriate; undefined behavior only occurs on execution of 
the call to free, not on compilation of the program.  A warning would be 
fine (as would converting the call to free into an abort).

-- 
Joseph S. Myers
[EMAIL PROTECTED]