Really, really const

Gabriel Dos Reis gdr@integrable-solutions.net
Fri Sep 26 08:30:00 GMT 2003


Andrew Haley <aph@redhat.com> writes:

| Gabriel Dos Reis writes:
|  > 
|  > 
|  > just a comment; I don't know what the is. But
|  > 
|  > [...]
|  > 
|  > | The memory a[0] is read twice.  Is there any attrribute I can use to
|  > | stop gcc from doing this?
|  > 
|  > GCC should be able to get that right without resorting to attributte
|  > hackery. 
| 
| I think the C standard says that gcc has to read the memory twice.

Which part says that?

In C++, the object a (and its subobjects [ai]) certainly are const
everywhere. 

| Just because that memory is declared const here that doesn't mean that
| it is const everywhere else; it just means that it's read-only here.
| It might change.

a[0] is not a volatile memory, right?  How can that memory change
without invoking undefined behaviour?

-- Gaby



More information about the Gcc mailing list