It is currently Sun May 31, 2020 1:21 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [PB5.72] Crash with empty Macro args
PostPosted: Thu May 14, 2020 9:19 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 2992
Location: Planet Earth
The following code is not correct, but it crashes the compiler or IDE.

Code:
Macro __DQ
    "
EndMacro

Macro MacroColon
  :
EndMacro

Macro JoinMacroParts (P1, P2=, P3=, P4=, P5=, P6=, P7=, P8=)
  P1#P2#P3#P4#P5#P6#P7#P8
EndMacro

Macro CreateMacro (name,macroBody)
  JoinMacroParts (Macro name, MacroColon, macroBody, MacroColon, EndMacro)
EndMacro

Macro Tst(_name_=)
    CreateMacro(a_b_cdefghijk_#_name_,Debug 1)
   
    CompilerIf Defined(a_b_cdefghijk_, #PB_Macro)
        Debug "Argument '_name_' is empty"
    CompilerElse
        Debug "Argument '_name_' is '"+__DQ#_name_#__DQ+"'"
    CompilerEndIf
    UndefineMacro a_b_cdefghijk_#_name_
EndMacro


Tst()         ; <= Corrupt internal macro arguments stack?
Tst(abc)

Compile within PB IDE, 1st time: It shows an syntax error at line 30:
Code:
Macro Debug 1abc: Debug 1: EndMacro
CompilerIf Defined(Debug 1, #PB_Macro)
    Debug "Argument '_name_' is empty"
CompilerElse
    Debug "Argument '_name_' is '"+"abc"+"'"
CompilerEndIf
UndefineMacro Debug 1abc

Somehow this unwrapped macro looks not right:
Code:
Macro Debug 1abc: Debug 1: EndMacro


Compile within PB IDE, 2nd time: IDE (or compiler?) crashes

If you remove the line 'Tst()' it compiles without crashing the IDE, but it is still wrong. (there is no #PB_Macro constant (unfortunately))

Looks like the compiler or IDE become very unstable when using 'param=' with macros (empty default args).

Tested with PB 5.72 LTS x64 macOS.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye