This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Compiling GCC With a C++ Compiler (g++)
Gabriel Dos Reis <gdr@cs.tamu.edu> writes:
> Look at the current implementation of build_string
>
> tree
> build_string (int len, const char *str)
> {
> tree s;
> size_t length;
[...]
> s = ggc_alloc_tree (length);
>
[...]
>
> return s;
> }
>
> The lvalue "s" is just nonmodifiable aoocording to the above language.
(You probably mean "*s", since s is not const qualified). But the object
returned by ggc_alloc_tree _is_ modfiable. And this is what matters here.
Just like
const int *foo() { return malloc (sizeof (int)); }
returns a pointer to a modfiable object, although the lvalue *foo() isn't.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."