develooper Front page | perl.perl5.porters | Postings from January 2013

[perl #4965] h2xs with -a flag screws up structs with arrays of elements

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
January 28, 2013 02:42
Subject:
[perl #4965] h2xs with -a flag screws up structs with arrays of elements
Message ID:
rt-3.6.HEAD-27190-1359340939-507.4965-15-0@perl.org
On Thu Jan 05 17:38:10 2012, jkeenan wrote:
> On Mon Dec 18 05:06:24 2000, joshw@yahoo-inc.com wrote:
> > This is a bug report for perl from joshw@ruminate.yahoo.com,
> > generated with the help of perlbug 1.28 running under perl v5.6.0.
> > 
> > Here's the jist of it:
> > 
> > test.h:
> > 	typedef struct _foo {
> > 	        char *name;
> > 	        int numbers[2];  // this causes the bomb
> > 	        char *garbage;
> > 	} foo;
> > 
> > $ h2xs -axAn Test `pwd`/test.h
> > Scanning typemaps...
> >  Scanning /usr/lib/perl5/5.6.0/ExtUtils/typemap
> > Scanning /home/joshw/dev/yahoo/hash/charthash/meow/test.h for
> >    functions...
> > Scanning /home/joshw/dev/yahoo/hash/charthash/meow/test.h for
> >    typedefs...
> > Writing Test/Test.pm
> > Writing Test/Test.xs
> > Writing Test/typemap
> > Writing Test/Makefile.PL
> > Writing Test/test.pl
> > Writing Test/Changes
> > Writing Test/MANIFEST
> > 
> > $ cd Test/
> > $ perl Makefile.PL && gmake
> > Checking if your kit is complete...
> > Looks good
> > Writing Makefile for Test
> > mkdir blib
> > mkdir blib/lib
> > mkdir blib/arch
> > mkdir blib/arch/auto
> > mkdir blib/arch/auto/Test
> > mkdir blib/lib/auto
> > mkdir blib/lib/auto/Test
> > mkdir blib/man3
> > cp Test.pm blib/lib/Test.pm
> > /usr/bin/perl -I/usr/lib/perl5/5.6.0/i386-freebsd
> >    -I/usr/lib/perl5/5.6.0 /usr/lib/perl5/5.6.0/ExtUtils/xsubpp
> >    -typemap /usr/lib/perl5/5.6.0/ExtUtils/typemap -typemap typemap
> >    Test.xs > Test.xsc && mv Test.xsc Test.c
> > cc -c  -I/usr/local/include -O     -DVERSION=\"0.01\"
> >    -DXS_VERSION=\"0.01\" -DPIC -fpic
> >    -I/usr/lib/perl5/5.6.0/i386-freebsd/CORE  Test.c
> > Test.xs: In function `XS_fooPtr_numbers':
> > Test.xs:61: incompatible types in assignment
> > Test.xs:62: warning: assignment makes integer from pointer without a
> >    cast
> > gmake: *** [Test.o] Error 1
> > 
> > [snip]
> 
> Are you sure it's the '-a' option that is causing the problem?
> 
> Tonight, using Perl 5.14.2 on Darwin, I was able to reproduce your error
> -- and got a warning to boot.
> 
> $ h2xs -axAn Test /Users/jimk/learn/perl/test_4965.h 
> Defaulting to backwards compatibility with perl 5.14.2
> If you intend this module to be compatible with earlier perl versions,
> please specify a minimum perl version with the -b option.
> 
> Writing Test/ppport.h
> Scanning typemaps...
>  Scanning /usr/local/lib/perl5/5.14.2/ExtUtils/typemap
> Scanning /Users/jimk/learn/perl/test_4965.h for functions...
> Scanning /Users/jimk/learn/perl/test_4965.h for typedefs...
> Writing Test/lib/Test.pm
> Use of uninitialized value in concatenation (.) or string at
> /usr/local/bin/h2xs line 1288.
> Writing Test/Test.xs
> Writing Test/typemap
> Writing Test/Makefile.PL
> Writing Test/README
> Writing Test/t/Test.t
> Writing Test/Changes
> Writing Test/MANIFEST
> $ cd Test
> $ perl Makefile.PL && make
> Checking if your kit is complete...
> Looks good
> Writing Makefile for Test
> Writing MYMETA.yml
> cp lib/Test.pm blib/lib/Test.pm
> /usr/local/bin/perl /usr/local/lib/perl5/5.14.2/ExtUtils/xsubpp 
> -typemap /usr/local/lib/perl5/5.14.2/ExtUtils/typemap -typemap typemap 
> Test.xs > Test.xsc && mv Test.xsc Test.c
> cc -c  -I. -fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe
> -I/usr/local/include -I/opt/local/include -O3   -DVERSION=\"0.01\"
> -DXS_VERSION=\"0.01\" 
> "-I/usr/local/lib/perl5/5.14.2/darwin-2level/CORE"   Test.c
> Test.xs: In function 'XS_fooPtr_numbers':
> Test.xs:63: error: incompatible types in assignment
> Test.xs:64: warning: assignment makes integer from pointer without a cast
> make: *** [Test.o] Error 1
> 
> 
> However, when I deleted the 'x' option from the 'h2xs' call, I was able
> to build successfully:
> 
> 
> $ h2xs -aAn Test /Users/jimk/learn/perl/test_4965.h 
> Defaulting to backwards compatibility with perl 5.14.2
> If you intend this module to be compatible with earlier perl versions,
> please
> specify a minimum perl version with the -b option.
> 
> Writing Test/ppport.h
> Writing Test/lib/Test.pm
> Writing Test/Test.xs
> Writing Test/Makefile.PL
> Writing Test/README
> Writing Test/t/Test.t
> Writing Test/Changes
> Writing Test/MANIFEST
> $ cd Test
> $ perl Makefile.PL && make
> Checking if your kit is complete...
> Looks good
> Writing Makefile for Test
> Writing MYMETA.yml
> cp lib/Test.pm blib/lib/Test.pm
> /usr/local/bin/perl /usr/local/lib/perl5/5.14.2/ExtUtils/xsubpp 
> -typemap /usr/local/lib/perl5/5.14.2/ExtUtils/typemap  Test.xs >
> Test.xsc && mv Test.xsc Test.c
> Please specify prototyping behavior for Test.xs (see perlxs manual)
> cc -c  -I. -fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe
> -I/usr/local/include -I/opt/local/include -O3   -DVERSION=\"0.01\"
> -DXS_VERSION=\"0.01\" 
> "-I/usr/local/lib/perl5/5.14.2/darwin-2level/CORE"   Test.c
> Running Mkbootstrap for Test ()
> chmod 644 Test.bs
> rm -f blib/arch/auto/Test/Test.bundle
> env MACOSX_DEPLOYMENT_TARGET=10.3 cc  -bundle -undefined dynamic_lookup
> -L/usr/local/lib -L/opt/local/lib Test.o  -o
> blib/arch/auto/Test/Test.bundle    \
>         \
>   
> chmod 755 blib/arch/auto/Test/Test.bundle
> cp Test.bs blib/arch/auto/Test/Test.bs
> chmod 644 blib/arch/auto/Test/Test.bs
> Manifying blib/man3/Test.3
> $ make test
> PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e"
> "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
> t/Test.t .. ok   
> All tests successful.
> Files=1, Tests=1,  0 wallclock secs ( 0.10 usr  0.03 sys +  0.10 cusr 
> 0.06 csys =  0.29 CPU)
> Result: PASS
> 
> Thank you very much.
> Jim Keenan

The OP has not responded to my response of one year ago, but perhaps
that's not surprising given that the original post was thirteen years
ago! :-(

I am taking the ticket for the purpose of closing it in seven days
unless someone has a serious objection.

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=4965

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About