Recent

Author Topic: Bug: cannot compile on Linux - when local types has same name  (Read 1498 times)

ydd

  • Jr. Member
  • **
  • Posts: 50
simple code example:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. type
  6.   TCompileTest1 = class
  7.   type
  8.     T = (t1);
  9.   const
  10.     S1: array[T] of String = ('t1');
  11.   end;
  12.  
  13.   TCompileTest2 = class
  14.   type
  15.     T = (t2);
  16.   const
  17.     S2: array[T] of String = ('t2');
  18.   end;
  19.  
  20. implementation
  21.  
  22. end.

Compile log:

Quote
Compile Project, Target: project1: Exit code 1, Errors: 2, Hints: 2
Hint: Start of reading config file /home/yd/Lazarus/trunk_210430/fpc/bin/x86_64-linux/fpc.cfg
Hint: End of reading config file /home/yd/Lazarus/trunk_210430/fpc/bin/x86_64-linux/fpc.cfg
Verbose: Free Pascal Compiler version 3.3.1-r49298 [2021/04/30] for x86_64
Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others
Verbose: Target OS: Linux for x86-64
Verbose: Compiling project1.lpr
Verbose: Compiling unit1.pas
Error: Asm: Duplicate label DBG_$UNIT1_$$_T
Error: Asm: Duplicate label DBGREF_$UNIT1_$$_T
Verbose: There were 2 errors compiling module, stopping
Verbose: Compilation aborted
Verbose: /home/yd/Lazarus/trunk_210430/fpc/bin/x86_64-linux/ppcx64 returned an error exitcode

on Windows I can compile without errors
« Last Edit: May 02, 2021, 01:50:58 am by ydd »

Bart

  • Hero Member
  • *****
  • Posts: 4360
    • Bart en Mariska's Webstek
Re: Cannot compile on Linux - when local types has same name
« Reply #1 on: April 30, 2021, 06:03:20 pm »
You must have different versions of the compiler on Windows vs Linux then.

Bart

howardpc

  • Hero Member
  • *****
  • Posts: 3729
Re: Cannot compile on Linux - when local types has same name
« Reply #2 on: April 30, 2021, 06:12:49 pm »
It may be a bug on Windows to allow two distinct types to have the same name. I think at least {$mode objfpc} disallows this.
But your unit has no mode specified, so presumably it takes the default mode.
Nor is it clear whether the compiler should generate shortstrings or some other string type.

ydd

  • Jr. Member
  • **
  • Posts: 50
Re: Cannot compile on Linux - when local types has same name
« Reply #3 on: May 01, 2021, 12:55:19 am »
You must have different versions of the compiler on Windows vs Linux then
I use latest trunk on both

ydd

  • Jr. Member
  • **
  • Posts: 50
Re: Cannot compile on Linux - when local types has same name
« Reply #4 on: May 01, 2021, 12:57:30 am »
It may be a bug on Windows to allow two distinct types to have the same name. I think at least {$mode objfpc} disallows this.
But your unit has no mode specified, so presumably it takes the default mode.

it is valid Pascal code, and it works everywhere else - Delphi, FPC for Windows & MacOS. {$mode objfpc} - does not matter.

Problem that in generated by compiler ASM code there are duplicate lines:

Code: Pascal  [Select][+][-]
  1. .globl  DBG_$UNIT1_$$_T

ydd

  • Jr. Member
  • **
  • Posts: 50
Re: Bug: cannot compile on Linux - when local types has same name
« Reply #5 on: May 04, 2021, 03:26:36 pm »
I believe that it is bug in compiler for Linux. Is it ok to create bug report? How?

ccrause

  • Sr. Member
  • ****
  • Posts: 402
Re: Bug: cannot compile on Linux - when local types has same name
« Reply #6 on: May 04, 2021, 04:46:16 pm »
I believe that it is bug in compiler for Linux. Is it ok to create bug report? How?

Create an account: https://bugs.freepascal.org/signup_page.php
Log an issue: https://bugs.freepascal.org/bug_report_page.php

 

TinyPortal © 2005-2018