Bug 402931

Summary: "swig -c++ -r" generates bad code
Product: [Fedora] Fedora Reporter: John Ellson <john.ellson>
Component: swigAssignee: Adam Tkac <atkac>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: ovasik
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-11-29 12:52:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Makefile
none
gv.i swig source file none

Description John Ellson 2007-11-28 15:06:42 UTC
Description of problem:
I'm trying to write a language binding for R for graphviz.   I'm successfully
using swig to generate ~10 other language bindings.

"swig -c++ -r gv.i"  generates bad code:
   - Missing:  #include <stdlib.h> 
   - error: invalid conversion from ‘const char*’ to ‘char*’
   - error: invalid conversion from ‘void*’ to ‘char*’


Version-Release number of selected component (if applicable):
swig-1.3.31-1.fc8.x86_64
gcc-c++-4.1.2-34.x86_64
R-2.6.1-1.fc9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. grab attached: Makefile, gv.i
2. make
3.
  
Actual results:
gv_r.cpp: In function ‘RCallbackFunctionData*
R_SWIG_pushCallbackFunctionData(SEXPREC*, SEXPREC*)’:
gv_r.cpp:759: error: ‘calloc’ was not declared in this scope
gv_r.cpp: In function ‘void R_SWIG_popCallbackFunctionData(int)’:
gv_r.cpp:800: error: ‘free’ was not declared in this scope
gv_r.cpp: In function ‘void R_SWIG_ReferenceFinalizer(SEXPREC*)’:
gv_r.cpp:888: error: ‘free’ was not declared in this scope
gv_r.cpp: In function ‘SEXPREC* RSwigPacked_New(void*, size_t, swig_type_info*)’:
gv_r.cpp:1000: error: ‘malloc’ was not declared in this scope
gv_r.cpp: In function ‘int SWIG_AsCharPtrAndSize(SEXPREC*, char**, size_t*, int*)’:
gv_r.cpp:1393: error: invalid conversion from ‘const char*’ to ‘char*’
....


Expected results:
no errors or warnings from swig generated code

Additional info:

Comment 1 John Ellson 2007-11-28 15:06:42 UTC
Created attachment 271381 [details]
Makefile

Comment 2 John Ellson 2007-11-28 15:07:55 UTC
Created attachment 271391 [details]
gv.i swig source file

Comment 3 Adam Tkac 2007-11-29 09:02:19 UTC
Looks like fixed in latest upstream. Could you please test
http://kojiweb.fedoraproject.org/koji/taskinfo?taskID=265131 ? Works for me.

Thanks

Comment 4 Adam Tkac 2007-11-29 12:52:28 UTC
after tests fixed in swig-1.3.33-1.fc{7,8,9}

Comment 5 John Ellson 2007-11-29 13:42:22 UTC
Much better, thanks.    Also no apparent new breakage to the other
swig-generated language bindings for graphviz.

    gv_r.cpp:725:2: warning: #warning "R Swig currently fails on runtime for 2.6
and higher."
   gv_r.cpp:726:2: warning: #warning "Contact maintainer if you would like to
help fix"

When I understand what this is about I'll take it up with the R maintainer.

Comment 6 Adam Tkac 2007-11-29 14:07:00 UTC
I'm not sure what exactly that warning mean. Tell it to R maintainer and if he
tells this is swig problem let me know

Thanks