Vadim Lobanov <[email protected]> writes: > However, if the code is as follows: > void foo (void) { > int myvar = 0; > printf("%d\n", myvar); > bar(&myvar); > printf("%d\n", myvar); > } > If bar is declared in _another_ file as > void bar (const int * var); > then I think the compiler can validly cache the value of 'myvar' for the > second printf without re-reading it. Correct/incorrect? Incorrect. bar() may cast away const. In C const does not mean readonly. Andreas. -- Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." - 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 [was Re: [PATCH 16/42]: PCI: PCI Error reporting callbacks]
- Prev by Date: Re: [PATCH 04/16] radix-tree: look-aside cache
- Next by Date: [PATCH 0/4] hugetlb: copy on write
- Previous by thread: Re: typedefs and structs - trim request
- Next by thread: Re: typedefs and structs
- Index(es):