Skip to content

It's a bug in the handling of the constant string

Summary

It's a bug in the handling of the constant string (the code that handles the constant value does not correctly handle the case of the string constant being a Unicode string constant unlike the code for expressions)

System Information

  • Operating system: Windows
  • Processor architecture: x86, x86-64
  • Compiler version: All
  • Device: Computer

Steps to reproduce

{$codepage utf8}
program project1; 
var
  ar: PChar = 'Ёжик';
begin
 Writeln(strlen(ar));  //Error
  Writeln(Length(Ar)); //Error
  ar := 'Ёжик';
  Writeln(strlen(ar)); //Ok
  Writeln(Length(Ar)); //Ok
  Readln;
end.   

Example Project

What is the current bug behavior?

What is the expected (correct) behavior?

Incorrect getting pchar variable value.

Relevant logs and/or screenshots

Possible fixes

Edited by Michael Van Canneyt
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information