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; void bar(const int *local_var) { foo = *local_var + 1; } void show(void) { printf("%d\n", foo); bar(&foo); printf("%d\n", foo); }If GCC thought it could arbitrarily cache anything it wanted to, then code like this would die. There is a whole mess of code in GCC designed specifically to watch for and avoid aliasing issues like these.
Cheers, Kyle Moffett --Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
-- Brian Kernighan - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: typedefs and structs
- From: Vadim Lobanov <[email protected]>
- Re: typedefs and structs
- 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 [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]
- Prev by Date: Re: Would I be violating the GPL?
- Next by Date: Re: [PATCH 8/8] Inline 3 functions
- Previous by thread: Re: typedefs and structs
- Next by thread: Re: typedefs and structs
- Index(es):