On Thu, 10 Nov 2005 11:28:27 -0800 (PST), Vadim Lobanov wrote: > On Thu, 10 Nov 2005, Kyle Moffett wrote: > > > On Nov 10, 2005, at 08:27:18, Nikita Danilov wrote: > > > extern declaration in your version of bar() cannot refer to the > > > automatic variable myvar in foo(). > > > > int foo; > > Except foo is not an automatic variable within show(). When the variable > is global, then there's no argument. It was a question of when foo is > local and bar() would get a const pointer to the local. > > > void bar(const int *local_var) { > > foo = *local_var + 1; > > } > > > > void show(void) { > > printf("%d\n", foo); > > bar(&foo); > > printf("%d\n", foo); > > } > > You can tweak it all as you want: int* foo_p; void bar(const int *local_var) { *foo_p = *local_var + 1; } int main() { int foo; foo_p = &foo; printf("%d\n", foo); bar(&foo); printf("%d\n", foo); return 0; } The fact is that gcc can't suppose anything unless you say explicitly it can. That is why 'pure' and 'const' __attributes__ exist, it supposes aliasing by default and so on. -- J.A. Magallon \ Software is like sex: werewolf!able!es \ It's better when it's free Mandriva Linux release 2006.1 (Cooker) for i586 Linux 2.6.14-jam1 (gcc 4.0.2 (4.0.2-1mdk for Mandriva Linux release 2006.1))