Hello!

I think this is a bug. But it's said not to report any bugs unless you're
sure that it's a bug, so I'm asking heer is this a bug?

template1=> select netmask('10.0.0.1/0');
        netmask
---------------
255.255.255.255
(1 row)

This happens because
word << shift
uses only 5 low bits of shift (this is described in docs on Intel processor).
Running 
word << 32
on sparc also gives unchanegd word 

I've included a patch for 6.5.
I think it will work with 6.5.1

-- 
Oleg.
*** src/backend/utils/adt/network.c     Sat Jul 17 11:01:02 1999
--- src/backend/utils/adt/network_fixed.c       Sat Jul 17 11:08:29 1999
***************
*** 452,458 ****
        if (ip_family(ip) == AF_INET)
        {
                /* It's an IP V4 address: */
!               int                     addr = htonl((-1 << (32 - ip_bits(ip))) & 
0xffffffff);
  
                if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
                        elog(ERROR, "unable to print netmask (%s)", strerror(errno));
--- 452,458 ----
        if (ip_family(ip) == AF_INET)
        {
                /* It's an IP V4 address: */
!               int                     addr = htonl(ip_bits(ip) ? (-1 << (32 - 
ip_bits(ip))) & 0xffffffff : 0x00000000);
  
                if (inet_net_ntop(AF_INET, &addr, 32, tmp, sizeof(tmp)) == NULL)
                        elog(ERROR, "unable to print netmask (%s)", strerror(errno));

Reply via email to