Menu

#671 GCC warning when passing by value a compatible pointer type

closed
dkl
None
compiler
2013-07-20
2013-05-05
No

Even after the fix:
#605 GCC warning about incompatible Parent/Child pointer types
it remains GCC warning messages when passing by value a compatible object pointer:


Type Parent
  Dim As Integer I
End Type
Type Child Extends Parent
End Type

Sub test_compatible_reference_by_ref (Byref p As Parent)
End Sub
Sub test_compatible_reference_by_val (Byval p As Parent)
End Sub

Sub test_compatible_pointer_by_ref (Byref pp As Parent Ptr)
End Sub
Sub test_compatible_pointer_by_val (Byval pp As Parent Ptr)
End Sub

Dim As Child c
test_compatible_reference_by_ref(c)
test_compatible_reference_by_val(c)

Dim As Child Ptr pc = New Child
test_compatible_pointer_by_ref(pc)
test_compatible_pointer_by_val(pc) '' warning: passing argument 1 of
                                   '' 'TEST_COMPATIBLE_POINTER_BY_VAL'
                                   '' from incompatible pointer type

Compiler output:
...\FBIDETEMP.c: In function 'main':
...\FBIDETEMP.c:120:2: warning: passing argument 1 of 'TEST_COMPATIBLE_POINTER_BY_VAL' from incompatible pointer type
...\FBIDETEMP.c:76:16: note: expected 'struct PARENT ' but argument is of type 'struct CHILD '

Remark:
- OK when passing byref a compatible object.
- OK when passing byval a compatible object.
- OK when passing byref a compatible object pointer.
- NOK (warning) when passing byval a compatible object pointer.

Warnings obviously disappear when using:
'test_compatible_pointer_by_val(Cast(Parent Ptr, pc))'

Referring to forum at post:
http://www.freebasic.net/forum/viewtopic.php?p=186850#p186850

Discussion

  • dkl

    dkl - 2013-07-20
    • status: open --> closed
    • assigned_to: dkl
     
  • dkl

    dkl - 2013-07-20

    Fixed by [a6e0e0]

     

    Related

    Commit: [a6e0e0]


Log in to post a comment.