View Issue Details

IDProjectCategoryView StatusLast Update
0038993FPCCompilerpublic2021-06-18 05:46
ReporterIan Upton Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version3.2.0 
Summary0038993: Incorrect structure of IN statement causes GDB breakpoint failure in Case statement.
DescriptionGentlefolk,
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
.
var
  vDebug : integer;
  vTestStr : String;

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

Ian
Steps To ReproduceSimply compile and execute the above code.

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

Activities

delfion

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

Gentlefolk,

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.

Ian.

Code:

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

var
  vDebug : integer;
  vTestStr : String;

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

end.
project1.zip (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

Woops,

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: project1.zip
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