View Issue Details

IDProjectCategoryView StatusLast Update
0038993FPCCompilerpublic2021-06-18 05:46
ReporterIan Upton Assigned To 
Status newResolutionopen 
Product Version3.2.0 
Summary0038993: Incorrect structure of IN statement causes GDB breakpoint failure in Case statement.
I have a simple case statement which processes input 'Key's for fields in a StringGrid.
Works well until vDebug = 8.

The code compiles clean but in debug mode with a breakpoint on the 'If in ['e..... statement the breakpoint is never triggered.

Look at the if statement, I have made a logical error in ['e'..'E'].

Replace ['e'..'E'] with ['e','E'], compiles clean and the breakpoint is triggered when vDebug = 8
  vDebug : integer;
  vTestStr : String;

  Case vDebug of
   1 : Begin
   2 : Begin
   8 : Begin
          If Key in ['e'..'E'] then
            vTestStr := vTestStr : char(key);

Steps To ReproduceSimply compile and execute the above code.

'Key' is a value from tStringGrid.Onkeydowwn(Sender , key........)
TagsNo tags attached.
Fixed in Revision
Attached Files



2021-06-12 06:28

reporter   ~0131269

This is not compilable example.

J. Gareth Moreton

2021-06-12 06:40

developer   ~0131270

It also helps to specify which platform you attempted to compile and debug this on, since there may be subtle differences in the compilation.

Ian Upton

2021-06-13 07:45

reporter   ~0131276


Apologies for the omissions.

The environment is Linux Mint 20.1 Cinamon, on an Lenovo X240 i3.

The attached file is a published basic single form application one gets when creating a new GUI application.

Simply added a StringGrid to the form and added the code to a tStringGrid1KeyDown

Run the project, click on any cell in the grid and depending on ['e'..'E']/['e','E'] the break point on 'Case 8' will either fail or succeed.



procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);

  vDebug : integer;
  vTestStr : String;

  vDebug := 8;
  Case vDebug of
   1 : Begin
   2 : Begin
   8 : Begin
          If char(Key) in ['e'..'E'] then
            vTestStr := vTestStr + char(key);

end. (128,188 bytes)

Serge Anvarov

2021-06-17 20:00

reporter   ~0131365

Did you read compiler warning?
First. "Warning: The first value of a set constructur range is greater then the second value, so the range describes an empty set". So, this expression always false.
Next. "Warning: unreachable code". That is, the code in this place is not generated (even without optimization). You can't put a breakpoint in an empty space, and that's fine.

Ian Upton

2021-06-18 05:46

reporter   ~0131373


They had rolled out of the small 'messages' display area and I ignored the message about warning messages because there are generally some warning messages in partially developed code.

Apologies for any inconvenience, Ian.

Issue History

Date Modified Username Field Change
2021-06-12 02:46 Ian Upton New Issue
2021-06-12 06:28 delfion Note Added: 0131269
2021-06-12 06:40 J. Gareth Moreton Note Added: 0131270
2021-06-12 10:30 Jonas Maebe Status new => feedback
2021-06-12 10:30 Jonas Maebe FPCTarget => -
2021-06-13 07:45 Ian Upton Note Added: 0131276
2021-06-13 07:45 Ian Upton File Added:
2021-06-13 07:45 Ian Upton Status feedback => new
2021-06-17 20:00 Serge Anvarov Note Added: 0131365
2021-06-18 05:46 Ian Upton Note Added: 0131373