Skip Menu |

This queue is for tickets about the Math-GMPz CPAN distribution.

Report information
The Basics
Id: 58501
Status: open
Priority: 0/
Queue: Math-GMPz

People
Owner: Nobody in particular
Requestors: BUBAFLUB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.29
Fixed in: (no value)



When compiling Math::GMPz 0.29 on Mac OS X 10.6 with GMP 4.3.1_1 and Perl 5.10. I successfully compiled Math::GMPz 0.28 on the same system previously. The error occurs with Random.c: gcc-4.2 -c -I/opt/local/include -arch x86_64 -arch i386 -arch ppc -g -pipe -fno- common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include -Os - DVERSION=\"0.29\" -DXS_VERSION=\"0.29\" "-I/System/Library/Perl/5.10.0/darwin- thread-multi-2level/CORE" Random.c Random.xs: In function ‘Rgmp_randinit_default’: Random.xs:13: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_mt’: Random.xs:28: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_lc_2exp’: Random.xs:43: warning: format not a string literal and no format arguments Random.xs:47: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs:47: error: (Each undeclared identifier is reported only once Random.xs:47: error: for each function it appears in.) Random.xs: In function ‘Rgmp_randinit_lc_2exp_size’: Random.xs:62: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs:66: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_set’: Random.xs:81: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_urandomb_ui’: Random.xs:95: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ Random.xs:95: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’ Random.xs: In function ‘Rgmp_randinit_default_nobless’: Random.xs:109: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_mt_nobless’: Random.xs:124: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_lc_2exp_nobless’: Random.xs:139: warning: format not a string literal and no format arguments Random.xs:143: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs: In function ‘Rgmp_randinit_lc_2exp_size_nobless’: Random.xs:155: warning: format not a string literal and no format arguments Random.xs:159: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs: In function ‘Rgmp_randinit_set_nobless’: Random.xs:171: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_default’: Random.xs:13: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_mt’: Random.xs:28: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_lc_2exp’: Random.xs:43: warning: format not a string literal and no format arguments Random.xs:47: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs:47: error: (Each undeclared identifier is reported only once Random.xs:47: error: for each function it appears in.) Random.xs: In function ‘Rgmp_randinit_lc_2exp_size’: Random.xs:62: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs:66: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_set’: Random.xs:81: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_urandomb_ui’: Random.xs:95: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ Random.xs:95: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’ Random.xs: In function ‘Rgmp_randinit_default_nobless’: Random.xs:109: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_mt_nobless’: Random.xs:124: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_lc_2exp_nobless’: Random.xs:139: warning: format not a string literal and no format arguments Random.xs:143: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs: In function ‘Rgmp_randinit_lc_2exp_size_nobless’: Random.xs:155: warning: format not a string literal and no format arguments Random.xs:159: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs: In function ‘Rgmp_randinit_set_nobless’: Random.xs:171: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_default’: Random.xs:13: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_mt’: Random.xs:28: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_lc_2exp’: Random.xs:43: warning: format not a string literal and no format arguments Random.xs:47: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs:47: error: (Each undeclared identifier is reported only once Random.xs:47: error: for each function it appears in.) Random.xs: In function ‘Rgmp_randinit_lc_2exp_size’: Random.xs:62: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs:66: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_set’: Random.xs:81: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_urandomb_ui’: Random.xs:95: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’ Random.xs:95: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’ Random.xs: In function ‘Rgmp_randinit_default_nobless’: Random.xs:109: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_mt_nobless’: Random.xs:124: warning: format not a string literal and no format arguments Random.xs: In function ‘Rgmp_randinit_lc_2exp_nobless’: Random.xs:139: warning: format not a string literal and no format arguments Random.xs:143: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs: In function ‘Rgmp_randinit_lc_2exp_size_nobless’: Random.xs:155: warning: format not a string literal and no format arguments Random.xs:159: error: ‘mp_bitcnt_t’ undeclared (first use in this function) Random.xs: In function ‘Rgmp_randinit_set_nobless’: Random.xs:171: warning: format not a string literal and no format arguments lipo: can't open input file: /var/folders/3R/3R3hKK62GTG1uUyK5ZU6Y++++TI/-Tmp- //ccL2n0uB.out (No such file or directory) make[1]: *** [Random.o] Error 1 make: *** [subdirs] Error 2 Let me know if you need any other information.
On Thu Jun 17 19:20:21 2010, BUBAFLUB wrote: Show quoted text
> When compiling Math::GMPz 0.29 on Mac OS X 10.6 with GMP 4.3.1_1 and > Perl 5.10.
Show quoted text
> Random.xs:43: warning: format not a string literal and no format > arguments
I have no idea why this warning appears, or of how to make it go away, but I will see if I can find out. Does this warning appear only with Random.xs ... or do you also get the same warning wrt New() in GMPz.xs ? It is only a warning, and probably not something to worry about, but it would be nice to eradicate it anyway. Show quoted text
> Random.xs:47: error: ‘mp_bitcnt_t’ undeclared (first use in this > function) > Random.xs:47: error: (Each undeclared identifier is reported only once
Damn!! I didn't realize the mp_bitcnt_t type doesn't exist in gmp libraries prior to version 5. First run 'make clean' Then, in Random.xs, just after '#include <gmp.h>' could you insert: #if __GNU_MP_VERSION < 5 #define mp_bitcnt_t unsigned long int #endif Then rebuild with 'perl Makefile.PL', 'make test'. Hopefully that will fix the error. Let me know how it goes, and I'll upload a fixed version to CPAN when the problem has been sorted. Show quoted text
> Random.xs: In function ‘Rgmp_urandomb_ui’: > Random.xs:95: warning: format ‘%d’ expects type ‘int’, but argument 2 > has type ‘long > unsigned int’
The occurrences of %d should be replaced with %u. I'll do that for the next release, too. Thanks for the report. Cheers, Rob
Show quoted text
> > I have no idea why this warning appears, or of how to make it go away, > but I will see if I can find out. Does this warning appear only with > Random.xs ... or do you also get the same warning wrt New() in GMPz.xs ? > It is only a warning, and probably not something to worry about, but it > would be nice to eradicate it anyway. >
Yes, the warnings also happen on GMPz.xs. Looks like calls to New() and Newz() Show quoted text
> > Damn!! I didn't realize the mp_bitcnt_t type doesn't exist in gmp > libraries prior to version 5. > > First run 'make clean' > Then, in Random.xs, just after '#include <gmp.h>' could you insert: > > #if __GNU_MP_VERSION < 5 > #define mp_bitcnt_t unsigned long int > #endif > > Then rebuild with 'perl Makefile.PL', 'make test'. > Hopefully that will fix the error. Let me know how it goes, and I'll > upload a fixed version to CPAN when the problem has been sorted. >
That works. Show quoted text
> The occurrences of %d should be replaced with %u. I'll do that for the > next release, too. >
I've attached a patch with both of these changes. WIth this patch`make test` passes on my machine. Show quoted text
> Thanks for the report. > > Cheers, > Rob
Lemme know if there is any other way I can help. b
Subject: math__gmpz.diff
diff --git Random/Random.xs Random/Random.xs index 336fa51..7a6667e 100644 --- Random/Random.xs +++ Random/Random.xs @@ -6,6 +6,10 @@ #include <stdlib.h> #include <gmp.h> +#if __GNU_MP_VERSION < 5 +#define mp_bitcnt_t unsigned long int +#endif + SV * Rgmp_randinit_default() { gmp_randstate_t * rand_obj; SV * obj_ref, * obj; @@ -92,7 +96,7 @@ SV * Rgmp_randinit_set(gmp_randstate_t * op) { SV * Rgmp_urandomb_ui(gmp_randstate_t * state, SV * n) { unsigned long max, req = (unsigned long)SvUV(n); max = sizeof(unsigned long) * 8; - if(req > max) croak("In Math::GMPz::Random::Rgmp_urandomb_ui, requested %d bits, but %d is the maximum allowed", req, max); + if(req > max) croak("In Math::GMPz::Random::Rgmp_urandomb_ui, requested %u bits, but %u is the maximum allowed", req, max); return newSVuv(gmp_urandomb_ui(*state, req)); }
On Fri Jun 18 11:30:22 2010, BUBAFLUB wrote: Show quoted text
> Lemme know if there is any other way I can help.
If you have Inline::C installed, could you run the below script and see if the warning appears during compilation of the C code - and whether it appears in relation to 'foo' only, or to 'bar' only, or in relation to both 'foo' and 'bar'. ######################## use warnings; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'EOC'; void foo() { int *x; New(1, x, 1, int); Safefree(x); printf("foo done\n"); } void bar() { int *x; Newx(x, 1, int); Safefree(x); printf("bar done\n"); } EOC foo(); bar(); ######################## Thanks again ! Cheers, Rob
On Sat Jun 19 01:13:17 2010, SISYPHUS wrote: Show quoted text
> > If you have Inline::C installed, could you run the below script and see > if the warning appears during compilation of the C code - and whether > it appears in relation to 'foo' only, or to 'bar' only, or in relation > to both 'foo' and 'bar'. > > ######################## > use warnings; > use Inline C => Config => > BUILD_NOISY => 1; > > use Inline C => <<'EOC'; > > void foo() { > int *x; > New(1, x, 1, int); > Safefree(x); > printf("foo done\n"); > } > > void bar() { > int *x; > Newx(x, 1, int); > Safefree(x); > printf("bar done\n"); > } > > EOC > > foo(); > bar(); > ######################## >
I installed the latest Inline::C from CPAN (0.46) and ran the script you provided. Here is the output: Starting Build Preprocess Stage Finished Build Preprocess Stage Starting Build Parse Stage Finished Build Parse Stage Starting Build Glue 1 Stage Finished Build Glue 1 Stage Starting Build Glue 2 Stage Finished Build Glue 2 Stage Starting Build Glue 3 Stage Finished Build Glue 3 Stage Starting Build Compile Stage Starting "perl Makefile.PL" Stage Writing Makefile for test_pl_e7da Finished "perl Makefile.PL" Stage Starting "make" Stage /usr/bin/perl /Library/Perl/Updates/5.10.0/ExtUtils/xsubpp -typemap /System/Library/Perl/5.10.0/ExtUtils/typemap -typemap /Users/bob/Desktop/work/math-- gmpz/typemap test_pl_e7da.xs > test_pl_e7da.xsc && mv test_pl_e7da.xsc test_pl_e7da.c gcc-4.2 -c -I/Users/bob/Desktop/work/math--gmpz -arch x86_64 -arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include -Os - DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" "-I/System/Library/Perl/5.10.0/darwin- thread-multi-2level/CORE" test_pl_e7da.c test_pl_e7da.xs: In function ‘foo’: test_pl_e7da.xs:8: warning: format not a string literal and no format arguments test_pl_e7da.xs: In function ‘bar’: test_pl_e7da.xs:15: warning: format not a string literal and no format arguments test_pl_e7da.xs: In function ‘foo’: test_pl_e7da.xs:8: warning: format not a string literal and no format arguments test_pl_e7da.xs: In function ‘bar’: test_pl_e7da.xs:15: warning: format not a string literal and no format arguments test_pl_e7da.xs: In function ‘foo’: test_pl_e7da.xs:8: warning: format not a string literal and no format arguments test_pl_e7da.xs: In function ‘bar’: test_pl_e7da.xs:15: warning: format not a string literal and no format arguments Running Mkbootstrap for test_pl_e7da () chmod 644 test_pl_e7da.bs rm -f blib/arch/auto/test_pl_e7da/test_pl_e7da.bundle gcc-4.2 -mmacosx-version-min=10.6 -arch x86_64 -arch i386 -arch ppc -bundle - undefined dynamic_lookup -L/usr/local/lib test_pl_e7da.o -o blib/arch/auto/test_pl_e7da/test_pl_e7da.bundle \ \ chmod 755 blib/arch/auto/test_pl_e7da/test_pl_e7da.bundle cp test_pl_e7da.bs blib/arch/auto/test_pl_e7da/test_pl_e7da.bs chmod 644 blib/arch/auto/test_pl_e7da/test_pl_e7da.bs Finished "make" Stage Starting "make install" Stage Files found in blib/arch: installing files in blib/lib into architecture dependent library tree Installing /Users/bob/Desktop/work/math-- gmpz/_Inline/lib/auto/test_pl_e7da/test_pl_e7da.bs Installing /Users/bob/Desktop/work/math-- gmpz/_Inline/lib/auto/test_pl_e7da/test_pl_e7da.bundle Finished "make install" Stage Starting Cleaning Up Stage Finished Cleaning Up Stage Finished Build Compile Stage foo done bar done Show quoted text
> Thanks again !
Looks like the warning is in the compilation stage. Does it matter that my gcc is 4.2? Show quoted text
> > Cheers, > Rob
b
Show quoted text
> Looks like the warning is in the compilation stage. Does it matter > that my gcc is 4.2? >
Answered my own question: On Snow Leopard (Mac OS X 10.6) with GCC 4.2 a lot of people have been getting this warning. Some links: * http://bobthegnome.blogspot.com/2009/07/format-not-string-literal-and-no- format.html * https://wiki.ubuntu.com/CompilerFlags#-Wformat%20-Wformat-security I can build without warnings by adding: use Inline C => Config => CCFLAGS => ' -Wno-format-security'; b
On Sat Jun 19 02:47:22 2010, BUBAFLUB wrote: Show quoted text
> I can build without warnings by adding: > > use Inline C => Config => CCFLAGS => ' -Wno-format-security';
Thanks for that - I just wanted to be sure that it wasn't something specific to gmp. I think the complaint relates to perl itself, so I'll leave it alone. It may already be fixed in later versions of perl, faik. The only way I can think of silencing the warning during builds of Math::GMPz would be to have the Makefile.PL's add ' -Wno-format- security' to CCFLAGS .... and I don't think that would be an appropriate thing to do. Thanks for investigating, and for establishing that ' -Wno-format- security' silences these particular warnings. I'll stick up a new version of Math::GMPz tomorrow (containing the changes already specified). Cheers, Rob