Re: casting const away





"copx" wrote in message news:ig3l22$3hb$1@xxxxxxxxxxxxxxxxxxxx Here's some compile-ready code which illustrates the issue:

#include <stdio.h>

void foo(const int *c)
{
*((int *)c) = 'B';
}


int main(void)
{
int a = 'A';
foo(&a);
putchar(a);
return 0;
}


====
Result: no warnings, prints 'B';

As I wrote in the other post I think I have figured it out
already.





.



Relevant Pages

  • Re: limits.h Sanity Issue
    ... Try posting a sample program which illustrates your problem. ... int main{ ...
    (comp.lang.c)
  • Re: how to avoid mistaken integer comparisons
    ... August Karlstrom writes: ... but only for integers with boolean interpretation. ... basically three cases and the code below illustrates what expression I ... int count; ...
    (comp.lang.c)
  • Re: can someone help me how to compile this program??
    ... int main ... i am using cygwin in window xp SP2, my gcc version is 3.4.4 ... can someone help me how to compile this program?? ... Any program that illustrates some particular point that's been trimmed ...
    (comp.lang.c)
  • Re: how to avoid mistaken integer comparisons
    ... Stephen Sprunk wrote: ... but only for integers with boolean interpretation. ... There are basically three cases and the code below illustrates what expression I think makes most sense in each case. ... int count; ...
    (comp.lang.c)
  • Segfault on new?
    ... I have a really simple program that illustrates a problem I'm ... an upgrade is in the works). ... Anywho, I have ... int main ...
    (microsoft.public.vc.language)