View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0035937 | FPC | RTL | public | 2019-08-07 17:38 | 2020-12-08 17:34 |
Reporter | Pierre Muller | Assigned To | Sergei Gorelkin | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.0.4 | ||||
Fixed in Version | 4.0.0 | ||||
Summary | 0035937: powerpc/powerpc64 bug | ||||
Description | fpc_pchar_to_shortstring in rtl/powerpc/powerpc.inc is wrong for p=nil! The output of the code below should be zero, but we get one for powerpc/powerpc64 at least on linux. Assigned to Sergei according to: [muller@gcc1-power7 powerpc]$ svn blame powerpc.inc | grep -nA22 pchar_to_short 1005: 8906 jonas procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);assembler;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc; nostackframe; 1006- 27832 sergei { 1007- 27832 sergei r3: result address 1008- 27832 sergei r4: high(result) 1009- 27832 sergei r5: p (source) 1010- 27832 sergei } 1011- 27832 sergei asm 1012- 27832 sergei { nil? } 1013- 27832 sergei mr r8, p 1014- 27832 sergei cmplwi p, 0 1015- 27832 sergei { load the begin of the string in the data cache } 1016- 27832 sergei dcbt 0, p 1017- 27832 sergei { maxlength } 1018- 27832 sergei mr r10,r4 1019- 27832 sergei mtctr r10 1020- 27832 sergei { at LStrPasDone, we set the length of the result to 255 - r10 - r4 } 1021- 27832 sergei { = 255 - 255 - 0 if the soure = nil -> perfect :) } 1022- 27832 sergei beq .LStrPasDone 1023- 27832 sergei { save address for at the end and use r7 in loop } 1024- 27832 sergei mr r7,r3 1025- 27832 sergei { no "subi r7,r7,1" because the first byte = length byte } | ||||
Steps To Reproduce | Compile the following few lines: var s : string; p : pchar; i : longint; begin p:=nil; s:=p; i:=length(s); writeln('Length of s is ',i); end. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | |||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
might be related? https://github.com/graemeg/freepascal/commit/40958efaea1f39424fae017b2517b0145a9c99f7 |
|
Indeed, this is supposed to fix the powerpc/powerpc64 specific bug. I was waiting to check what the new test gives on all platforms before changing the status of this bug report to fixed! Pierre |
|
Should be fixed due to commit #42603 |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-08-07 17:38 | Pierre Muller | New Issue | |
2019-08-07 17:38 | Pierre Muller | Status | new => assigned |
2019-08-07 17:38 | Pierre Muller | Assigned To | => Sergei Gorelkin |
2019-08-08 17:20 | rd0x | Note Added: 0117593 | |
2019-08-08 17:28 | Pierre Muller | Note Added: 0117594 | |
2020-12-08 17:34 | Pierre Muller | Status | assigned => resolved |
2020-12-08 17:34 | Pierre Muller | Resolution | open => fixed |
2020-12-08 17:34 | Pierre Muller | Fixed in Version | => 4.0.0 |
2020-12-08 17:34 | Pierre Muller | FPCTarget | => - |
2020-12-08 17:34 | Pierre Muller | Note Added: 0127462 |