dkl - 2016-03-09
  • Description has changed:

Diff:

--- old
+++ new
@@ -1,6 +1,6 @@
 fbc currently allows forward references to be used for Byref parameters in procedure declarations.

-This is a problem, because the parser doesn't (and can't with its current design) verify the argument while the parameter type is incomplete. Thus it allows passing incompatible things which results in bad code being generated.
+This is a problem, because the parser doesn't (and can't with its current design) verify the argument while the parameter type is incomplete. Thus it allows passing incompatible things which results in bad code being generated. 

     type UDT as UDT_

@@ -20,3 +20,19 @@
     sub f(byref x as UDT)
         print x.a, x.b
     end sub
+
+
+    mov byte ptr [ebp-20], 1     # integer 1, but byte ptr!?
+    lea eax, [ebp-20]
+    push eax
+    call F
+
+    mov byte ptr [ebp-36], 4607182418800017408    # double 1.0, but byte ptr!?
+    lea eax, [ebp-36]
+    push eax
+    call F
+
+The procedure expects an argument of type UDT, not integer/double, but fbc does
+not diagnose the problem. It looks like -gen gas falls back to ``byte ptr`` in case of ``FB_DATATYPE_FWDREF``.
+
+Similar problems with -gen gcc (bad C code generated, does not compile).