Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler bug in gdiplus.pas #7

Open
EganSolo opened this issue Mar 29, 2021 · 1 comment
Open

Compiler bug in gdiplus.pas #7

EganSolo opened this issue Mar 29, 2021 · 1 comment

Comments

@EganSolo
Copy link

Lazarus 2.0.12
FPC 3.2.0
SVN Revision: 64642.
Downloaded the zip file code.codebot-master
loaded the package codebot and hit compile.
Compilation error in gdiplus.pas, line 11906: Can't determine which overloaded function to call. Function in question is TGdiBitmap.create(size * 2, Size * 2)
This is really weird. I checked all the constructors you have in this class:

  {01}  constructor Create(Bitmap                       : GpBitmap                                                                                ); overload;
  {02}  constructor Create(Filename                    : WideString; UseEmbeddedColorManagement: Boolean = False); overload;
  {03}  constructor Create(Stream                      : IStream      ; UseEmbeddedColorManagement: Boolean = False); overload;
  {04}  constructor Create(Width, Height, Stride : Integer       ; Format                                       : TPixelFormat     ;
                                        scan0                        : PByte                                                                                       ); overload;
  {05}  constructor Create(Width, Height            : Integer      ; Format: TPixelFormat = PixelFormat32bppArgb     ); overload;
  {06}  constructor Create(Width, Height            : Integer      ; Target : IGdiGraphics                                             ); overload;
  {07}  constructor Create(surface                       : IDirectDrawSurface7                                                                ); overload;
  {08}  constructor Create(var BitmapInfo           : TBitmapInfo; BitmapData                                : Pointer            ); overload;
  {09}  constructor Create(Bmp                          : HBitmap      ; Pal                                             : HPALETTE        ); overload;
  {10}  constructor Create(Icon                          : HICON                                                                                     ); overload;
  {11}  constructor Create(hInstance                 : HMODULE  ; BitmapName                               : WideString      ); overload;

It seems to me that the call at line 11906 is calling constructor number 5 which has a signature that is different from the signatures of the other constructors. Further, the superclass TGDImage does not have a constructor that could clash with constructor number 5. The same holds true for TInterfacedObjet and TObject.

Could that be a bug in the compiler?

@EganSolo
Copy link
Author

I'm on Win64 and the compiler is getting confused between declarations 5 and 9 because you're making a call that's passing 2 * Size, and that could be interpreted as a Qword if 2 * size overflows the integer bounds.

Solution: If you're certain that 2 * Size will always be less than MaxInt, then either typecast 2 * Size to integer when passing it or assign it to an integer variable before making the call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant