Recent

Author Topic: [SOLVED] Error TStringHelper.LastIndexOf ?  (Read 568 times)

Thausand

  • Full Member
  • ***
  • Posts: 234
[SOLVED] Error TStringHelper.LastIndexOf ?
« on: April 01, 2019, 10:25:48 am »
I write
Code: Pascal  [Select]
  1. program testerror;
  2.  
  3. {$MODE OBJFPC}{$H+}
  4.  
  5. uses
  6.   sysutils;
  7.  
  8. var
  9.   s1,s2: String;
  10.   n: integer;
  11. begin
  12.   s1:= 'TEST3';
  13.   s2:= 'TEST1/TEST2/TEST3';
  14.   n:= s2.LastIndexOf(s1);
  15.   WriteLn('n = ', n);
  16. end.
  17.  

I compile
Code: [Select]
fpc -B -glh testerror.pas
Free Pascal Compiler version 3.0.4-r37149 [2019/03/13] for arm
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling testerror.pas
Assembling testerror
Linking testerror
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
16 lines compiled, 0.1 sec

I run:
Code: [Select]
$ ./testerror

Write me
Code: [Select]
Segmentation fault

I not understand. I make error ?
« Last Edit: April 01, 2019, 01:22:26 pm by Thausand »

ptvs

  • New member
  • *
  • Posts: 6
Re: Error TStringHelper.LastIndexOf ?
« Reply #1 on: April 01, 2019, 12:30:10 pm »
No, this method is not implemented in FPC 3.0.4

Thaddy

  • Hero Member
  • *****
  • Posts: 9293
Re: Error TStringHelper.LastIndexOf ?
« Reply #2 on: April 01, 2019, 01:09:39 pm »
No, this method is not implemented in FPC 3.0.4
No it is already in 3.0.4. (Otherwise it would not compile). It may be that there was a bug which should be fixed in FPC 3.2.0.
Anyway your code compiles and works with 3.2.0 and trunk 3.3.1-41807. I tested on Raspbian Jessie.
« Last Edit: April 01, 2019, 01:15:16 pm by Thaddy »
also related to equus asinus.

Thausand

  • Full Member
  • ***
  • Posts: 234
Re: Error TStringHelper.LastIndexOf ?
« Reply #3 on: April 01, 2019, 01:21:50 pm »
No it is already in 3.0.4. (Otherwise it would not compile). It may be that there was a bug which should be fixed in FPC 3.2.0.
Ok. i just see source and is there 3.0.4. Thank for say Thaddy

Quote
Anyway your code compiles and works with 3.2.0 and trunk 3.3.1-41807. I tested on Raspbian Jessie.
Many thank for try 3.2.0. I now usage more better solution and not use LastIndexOf  :)

I also try 3.2.0 and write that work. I solve thread. Fix is 3.2.0 not use LastIndexOf fpc 3.0.4