On Thu, 10 Nov 2005 11:28:27 -0800 (PST), Vadim Lobanov <[email protected]> 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 <jamagallon()able!es> \ 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))
Attachment:
signature.asc
Description: PGP signature
- References:
- Re: typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]
- From: linas <[email protected]>
- Re: typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]
- From: Steven Rostedt <[email protected]>
- Re: typedefs and structs
- From: linas <[email protected]>
- Re: typedefs and structs
- From: Kyle Moffett <[email protected]>
- Re: typedefs and structs
- From: linas <[email protected]>
- Re: typedefs and structs
- From: Douglas McNaught <[email protected]>
- Re: typedefs and structs
- From: linas <[email protected]>
- Re: typedefs and structs
- From: Kyle Moffett <[email protected]>
- Re: typedefs and structs
- From: "J.A. Magallon" <[email protected]>
- Re: typedefs and structs
- From: Vadim Lobanov <[email protected]>
- Re: typedefs and structs
- From: linas <[email protected]>
- Re: typedefs and structs
- From: "linux-os \(Dick Johnson\)" <[email protected]>
- Re: typedefs and structs
- From: Vadim Lobanov <[email protected]>
- Re: typedefs and structs
- From: "J.A. Magallon" <[email protected]>
- Re: typedefs and structs
- From: Nikita Danilov <[email protected]>
- Re: typedefs and structs
- From: Kyle Moffett <[email protected]>
- Re: typedefs and structs
- From: Vadim Lobanov <[email protected]>
- Re: typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]
- Prev by Date: Re: [PATCH 1/1] My tools break here
- Next by Date: Re: [PATCH] kbuild updates
- Previous by thread: Re: typedefs and structs
- Next by thread: Re: typedefs and structs
- Index(es):