Subject: | trying to add an element twice prevents further adds to the set |
Date: | Tue, 08 Dec 2009 11:22:52 +0100 |
To: | bug-Set-Scalar [...] rt.cpan.org |
From: | Eduard Wulff <mail [...] eduard-wulff.de> |
Hi,
I am quality checking report definitions.
Writing my check program I think I found a bug (see subject and the
attached program to reproduce the bug.
( same bug on Ubuntu 9.10 )
Set::Scalar 1.24
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
Platform:
osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
uname='Win32 strawberryperl 5.10.1.0 #1 30 i386'
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT
-DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-fno-strict-aliasing -DPERL_MSVCRT_READFIX',
optimize='-s -O2',
cppflags='-DWIN32'
ccversion='', gccversion='3.4.5', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long
long', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE"
-L"C:\strawberry\c\lib"'
libpth=C:\strawberry\c\lib
libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32
perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool
-lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid
-lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32
libc=, so=dll, useshrplib=true, libperl=libperl510.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE"
-L"C:\strawberry\c\lib"'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_SITECUSTOMIZE
Built under MSWin32
Compiled at Oct 21 2009 13:54:15
@INC:
c:/strawberry/perl/lib
c:/strawberry/perl/site/lib
C:\strawberry\perl\vendor\lib
.
PsInfo v1.75 System information
Kernel version: Microsoft Windows XP, Multiprocessor Free
Product type: Professional
Product version: 5.1
Service pack: 3
Kernel build number: 2600
IE version: 8.0000
System root: C:\WINDOWS
Processors: 2
Processor speed: 2.3 GHz
Processor type: Intel(R) Core(TM)2 Duo CPU P8600 @
Physical memory: 3572 MB
#!perl
use Modern::Perl;
use Set::Scalar 1.24;
my $reportzeilenelemente = Set::Scalar->new();
addelement(2);
# Trying to add an element twice prevents adding further elements
# expected behaviour: do nothing, especially DO NOT prvent adding further elements
addelement(2);
addelement(3);
addelement(34);
sub addelement {
my $new_ele = shift;
if ( $reportzeilenelemente->has($new_ele) ) {
warn "Warnung! Knoten $new_ele kommt doppelt vor!\n";
}
# possible workaround: check if element exists before you add it
# else {
print $reportzeilenelemente->size . " ";
$reportzeilenelemente = $reportzeilenelemente + $new_ele;
say "Element $new_ele hinzugefuegt. " . $reportzeilenelemente->size;
# }
}