RTTI.Invoke string treatment depends on {$H} setting
## Summary <!-- Summarize the bug encountered concisely --> With {$H+}, string passed to RTTI.Invoke is accessed correctly. Otherwise, it's like trying to treat a shortstring as an ansistring. ## System Information <!-- The more information are provided the easier it is to replicate the bug --> - **Operating system:** Linux<!-- Windows, Linux (if possible, also name the distro), FreeBSD, Android, ... --> - **Processor architecture:** x86_64<!-- x86, x86-64, ARM, AARCH64, AVR, RISC-V, PowerPC, ... --> - **Compiler version:** bb182470a563483803883b01f1a9b4ea3cd7d0fc<!-- 3.2, 3.2.2, 3.3, trunk, beta, ... (if possible, give also the git hash) --> - **Device:** Laptop<!-- Computer, Tablet, Mobile, Amiga, Microcontroller, ... --> ## Steps to reproduce <!-- How one can reproduce the issue - this is very important! --> Compile and run the following code: ```pascal {$ H+} uses rtti, typinfo, {$ifndef win64} ffi.manager; {$endif} procedure p(s: String); begin WriteLn(s); end; var a: TValueArray; begin a := ['hello']; Invoke(@p,a,ccReg,nil,false,false); end. ``` The output will be garbage like: ello�?@�?� @�?��� Change the {$ H+} into {$H+} and it will output: hello ## Example Project <!-- If possible, please create an example project that exhibits the problematic behavior, and link to it here in the bug report. --> ## What is the current bug behavior? <!-- What actually happens --> Seems like a shortstring is treated as an ansistring ## What is the expected (correct) behavior? <!-- What you should see instead --> With or without {$H+}, it should output: hello ## Relevant logs and/or screenshots <!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code, as it's very hard to read otherwise. You can also use syntax highlighting for Pascal with: ```pascal the code``` For more information see https://docs.gitlab.com/ee/user/markdown.html --> ## Possible fixes <!-- If you can, link to the line of code that might be responsible for the problem --> I think this is due to missing operator := definition for shortstring in TValue record, but somehow the compiler managed to think that the shortstring can be treated like an ansistring. Declaring: ```pascal operator := (const AValue: ShortString) Result: TValue; inline; begin TValue.Make(@AValue, System.TypeInfo(AValue), Result); end; ``` in above program is sufficient to solve the problem. A proper implementation has been done in the linked merge request, tested and proven to be working.
issue