--- layout: fc_discuss_archives title: Message 40 from Frama-C-discuss on April 2011 ---
Hi Pascal, The const is erased from just int const i = 0; as well. The results from gcc -E does preserve the const keyword. I suspected that the splitting of the declaration and definition was the reason that the keyword was dropped. I do an iteration through the list of attributes and I don't see any other keywords there. As it stands now I have to go back to the source files and look at the text to see if the keyword is there or not! Thanks for you time, Wayne -----Original Message----- From: frama-c-discuss-bounces at lists.gforge.inria.fr on behalf of Pascal Cuoq Sent: Fri 4/22/2011 1:31 PM To: Frama-C public discussion Cc: <frama-c-discuss at lists.gforge.inria.fr> Subject: Re: [Frama-c-discuss] const pointer in local variable On 22 avr. 2011, at 18:51, "Wayne Pineault" <wpineault at dsci.com> wrote: > I am trying to access the const pointer attribute in > > int * const p; > > For global variables the attribute list for the TPtr typ contains the const but for variables in a function it does not. > > Why are local variables treated differently than global ones? > Speaking as a non-specialist, I would guess that the const is erased for local variables because of the way their initialization is transformed into an assignment. We could remove this transformation completely (it seems to cause more harm than good for static analysis) or add a dedicated attribute other than const so as not to confuse compilers which have to parse transformed C code. By the way, did you check whether there wasn't already such an attribute? It sounds like the kind of hack that might already exist(there is a similar one in place for arrays as function arguments). Pascal -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/ms-tnef Size: 3718 bytes Desc: not available URL: <http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20110422/c6b1191f/attachment.bin>