Tim Bunce wrote:
On Mon, Mar 10, 2003 at 10:51:21PM -0500, Matthew O. Persico wrote:

I am using Perl 5.6.1, DBI 1.32 and DBD::Oracle 1.12. I have decided to upgrade to DBI 1.35 BEFORE reporting a problem I am having.

I built DBI 1.35 with no problems. Then I tried to rebuild DBD::Oracle 1.12.

1) compile warning:
cc -c -I/opt/oracle/product/8.1.6/rdbms/demo
-I/opt/oracle/product/8.1.6/rdbms/public
-I/opt/oracle/product/8.1.6/plsql/public
-I/opt/oracle/product/8.1.6/network/public
-I/opt/oracle/product/8.1.6/rdbms/demo -I/opt/oracle/product/8.1.6/rdbms/demo
-I/opt/perl/lib/site_perl/5.6.1/sun4-solaris/auto/DBI -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O    -DVERSION=\"1.12\"
-DXS_VERSION=\"1.12\" -KPIC -I/opt/perl/lib/5.6.1/sun4-solaris/CORE  oci8.c
"oci8.c", line 267: warning: assignment type mismatch:
       pointer to function(pointer to struct imp_dbh_st {struct {..} com,
pointer to function(pointer to struct imp_dbh_st {..}, in... "=" pointer to void

This is probably NOT due to DBI 1.35, but I thought I'd report it anyway.

Thanks. It's not DBI related. And it's odd that the compiler is warning about an assignment involving a void* pointer.

Functions aren't objects. Void pointers can point to any object and void pointers are pretty interchangeable (within limits). But pointers to functions are neither interchangeable with pointers to void nor with pointers to other objects, in general. Technically, a int (*pfri)() [pointer to function returning int] cannot be converted to other function pointer types such as void *(*pfrvp)(size_t) [pointer to function taking size_t and returning a pointer to void] or even int (*pfvri)(void) [pointer to function taking void and returning int - the other one has unspecified arguments rather than zero arguments in C (but zero arguments in C++)]. In practice, I'm not aware of any hardware where there is a significant problem, but some mainframes (Burroughs, ICL) may have issues. But the standard (C standard, that is) does say that pointers to functions aren't convertible. So, using a void (*generic_function_ptr)() interchangeably is practically safe, but theoretically unsafe so a compiler can (maybe even is supposed to) warn about the behaviour.


Consider using a union:

union { void *vp; void (*fp)(); };

However, there's no guarantee that will quell an over-zealous compiler.

2) testing:

Because of this in DBI.pm:

sub connect {
    my $class = shift;
    my ($dsn, $user, $pass, $attr, $old_driver) = my @orig_args = @_;
    my $driver;

    if ($attr and !ref($attr)) { # switch $old_driver<->$attr if called in old style
->>>      Carp::croak("DBI->connect using 'old-style' syntax is deprecated and will be an 
error in future versions");
        ($old_driver, $attr) = ($attr, $old_driver);
    }

(which doesn't make sense to me because the croak seems to make the old-style
syntax be an error in this version!)


Uh, that should have been a carp! Of well, that'll get people to fix their scripts!
But I'll change it to a carp for the next release.

And back to croak a release or two later :-) Mind you, I've fixed the tests in DBD::Informix which explicitly tested the old connect syntax. There were about 3 of them.



--
Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED]) #include <disclaimer.h>
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/




Reply via email to