mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 18:47:52 +02:00
* call the ansistring version of val for zero-based array-of-char
parameters (because they can be auto-converted to ansistring, but not to shortstring) (mantis #8148) git-svn-id: trunk@6076 -
This commit is contained in:
parent
3e153102a8
commit
a3f059bc29
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7975,6 +7975,7 @@ tests/webtbs/tw8140g.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8140h.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8141.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8145.pp svneol=native#text/plain
|
||||
tests/webtbs/tw8148.pp svneol=native#text/plain
|
||||
tests/webtbs/ub1873.pp svneol=native#text/plain
|
||||
tests/webtbs/ub1883.pp svneol=native#text/plain
|
||||
tests/webtbs/uw0555.pp svneol=native#text/plain
|
||||
|
@ -1050,6 +1050,9 @@ implementation
|
||||
{ the shortstring-longint val routine by default }
|
||||
if (sourcepara.resultdef.typ = stringdef) then
|
||||
procname := procname + tstringdef(sourcepara.resultdef).stringtypname
|
||||
{ zero-based arrays (of char) can be implicitely converted to ansistring }
|
||||
else if is_zero_based_array(sourcepara.resultdef) then
|
||||
procname := procname + 'ansistr'
|
||||
else
|
||||
procname := procname + 'shortstr';
|
||||
|
||||
|
25
tests/webtbs/tw8148.pp
Normal file
25
tests/webtbs/tw8148.pp
Normal file
@ -0,0 +1,25 @@
|
||||
program ValVsArrayOfChar;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$mode delphi}
|
||||
{$ENDIF}
|
||||
|
||||
procedure test(a: ansistring);
|
||||
begin
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
Code : Integer;
|
||||
D : Double;
|
||||
s : Array[byte] of Char;
|
||||
begin
|
||||
s := '123';
|
||||
test(s);
|
||||
Val(s, D, Code); // compiles only in delphi
|
||||
if (abs(d-123.0) > 0.00001) then
|
||||
halt(1);
|
||||
Val(PChar(@s), D, Code); // compiles in both delphi and FPC
|
||||
if (abs(d-123.0) > 0.00001) then
|
||||
halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user