assignment of typed const pointer types have correct but cryptic error message.
Original Reporter info from Mantis: Thaddy
-
Reporter name: Thaddy de Koning
Original Reporter info from Mantis: Thaddy
- Reporter name: Thaddy de Koning
Description:
typed consts of a pointer type can not be assigned to eachother at compile time for the following reasons:
- Typed consts have a memory location. They are actually a restricted type of var.
- The two pointer types p and b of type PWideChar therefor are each a different memory address.
- Typed consts do not have copy semantics for pointer types at declaration time:the address b can not be the address p.
But the error message is rather cryptic. Maybe this can be improved somewhat, like "Error: Typed consts of pointer types can not be assigned to each other at declaration time."
Steps to reproduce:
program PwidecharIssue;
{$MODE OBJFPC}
{$WRITEABLECONST ON}
const
test :array[0..0] of PWidechar = ('some value');
p: pwidechar = @test[0];
b: pwidechar = p;
// Error: Incompatible types: got "SYSTEM.PWideChar" expected "SYSTEM.PWideChar"
// This is indeed correct (p and b are different pointers) but cryptic
end.
Additional information:
Maybe also needs an update of the documentation.
Mantis conversion info:
- Mantis ID: 34054
- OS: all
- OS Build: all
- Platform: all
- Version: 3.1.1
- Fixed in version: 3.3.1
- Fixed in revision: 46931 (#dfc485c4)