Skip to content

Generic with consts wrong behavior

Summary

Only first const is taken, other are ignored

System Information

  • Operating system: Windows
  • Processor architecture: x86-64
  • Compiler version: trunk

Steps to reproduce

program Project1;
{$mode objfpc}{$H+}

type
  generic GTestType<T,const S:byte>=class
    type
      TXX=array [0..S] of T;
    var
      XX:TXX;
  end;
  T2=specialize GTestType<byte,0>;
  T3=specialize GTestType<byte,99>;
begin
  writeln(sizeof(T2.TXX));
  writeln(sizeof(T3.TXX));
  readln;
end.

What is the current bug behavior?

this gives:

1

1

What is the expected (correct) behavior?

should be (imho):

1

100

Edited by Andrey Zubarev
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information