Ticket #340 (Fixed)Fri Mar 29 15:56:02 UTC 2013
Norcroft (possibly) incorrectly decorates pointer/array typedef as readonly
Reported by: | Rob Kendrick (86) | Severity: | Normal |
Part: | RISC OS: C/C++ toolchain | Release: | |
Milestone: | Status | Fixed |
Details by Rob Kendrick (86):
bc..#include <stdlib.h>
typedef unsigned char byte;
typedef byte Charset123;
void test(const Charset follow)
{
follow = NULL;
}
*cc -strict -c99 -fah -Wh -Otime SSEx4nim.c
Norcroft RISC OS ARM C vsn 5.69 [20 Oct 2010]
“c.SSEx4nim”, line 7: Warning: extern ‘test’ not declared in header
“c.SSEx4nim”, line 8: Error: assignment to ‘const’ object ‘follow’
c.SSEx4nim: 1 warning, 1 error, 0 serious errors
p.
This code compiles warning-free on gcc, clang, and EDG-based compilers. It appears to be misidentifying which part of the type expression should be read-only. This might be an ambiguity in the spec, but if so it would be nice if it interpreted it the same way as all the other popular compilers.
(I have no idea if this is fixed in a later version, I do not have Norcroft and this has been diagnosed using remote-hands)
Changelog:
Modified by Sprow (202) Tue, August 08 2017 - 15:35:03 GMT
cc 5.72 produces the same error message
Modified by Marco Schmidt (2373) Wed, October 05 2022 - 13:57:58 GMT
The error message is correct and the code does not compile on modern CLANG and GCC (see also https://godbolt.org/z/GzTP1axK8)
Modified by Jeffrey Lee (213) Tue, November 15 2022 - 01:37:29 GMT
Marco: The bug tracker has mangled the source code a bit – Charset isn’t a single byte, it’s an array of 123 bytes.
https://godbolt.org/z/a3rbG67Kq
The latest version of cc (5.90) still produces the error.
Modified by Sprow (202) Fri, March 01 2024 - 07:34:50 GMT
- Status changed from Open to Fixed
Changelog (and empirical test) confirms this behaviour was changed in cc 5.92 to match other popular compilers.