generics accept a comparison of an unspecialized T to (pointer) nil.
Original Reporter info from Mantis: Thaddy
-
Reporter name: Thaddy de Koning
Original Reporter info from Mantis: Thaddy
- Reporter name: Thaddy de Koning
Description:
generics (both modes) accept a comparison of T to nil.
T need not be of a pointer type.
Delphi does not accept such syntax.
Steps to reproduce:
{$ifdef fpc}{$mode objfpc}{$modeswitch advancedrecords}{$H+}{$endif}
type
generic Ttestme<T> = record
private
bar:T;
public
procedure foo;
end;
procedure Ttestme.foo;
begin
if bar <> nil then writeln('How do you know T is a ponter type?');
end;
begin
end.
// the above compiles without warning but:
// now, use it:
var a:specialize TTest<integer>;
begin
a.foo;
end.
Additional information:
The comparison to pointer should never been accepted.
Delphi mode also accepts it. Delphi itself does not accept it. Delphi is right.
Mantis conversion info:
- Mantis ID: 33961
- OS: all
- OS Build: all
- Build: 39423
- Platform: all
- Version: 3.1.1
- Fixed in version: 3.1.1