On 10 October 2012 06:48, Anthony Toft wrote: > Only it doesn't, prevent array access > > p[1] =3D 3; > p + 1 =3D 2; > > don't fail (there is no assignment to the value of p) > Very good point here, C is a very loose language, and there are no real security measurements in it (such as compile and runtime validations like the one used in Ada). Usually I blame the intense use of C and C derivate languages for the software vulnerabilities existing in numerous of compressional and open source products. Tamas > > On 2012-10-10 09:32, Isaac Marino Bavaresco wrote: > > Em 10/10/2012 10:09, Anthony Toft escreveu: > >> But why? (the bane of my parent's existence) > >> > >> p++; only increments the value of the pointer on the stack, not the > >> original pointer (&myInt or &anotherInt) nor the contents of the > >> pointer. > >> > >> Here at work (I am 18 years into a software engineering career) I > >> see > >> examples of unnecessary const-ness all over the place, it causes any > >> amount of trouble! The only time I have ever needed a > >> is > >> because of overzealous use of const parameters, the compiler will > >> not > >> remove const-ness without express permission, unlike adding it. > >> > >> Now, on the other hand, pointers to const objects or values ie > >> "const > >> int *p" I feel is an excellent idea, but once again, it's not the > >> calling function saying "I won't allow him to change this" it's the > >> called function saying "I promise I won't change it" > > > > > > Useful to prevent the callee function from using the pointer as a > > pointer to an array when it points to a single element. > > > > > > Isaac > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .