[Bug c++/35480] New: Relational operators for don't error on different sized tuples

2008-03-06 Thread gryan at akoostix dot com
According to the 6.1.3.5 [tr.tuple.rel], there is an implicit dependencies on
the sizes of the tuples being compared, and there should be a compilation
failure if the tuples are not the same size.

However I am not seeing compilation errors in this case. The following example
compiles and runs. Below that is the output from compilation with " g++ -v
-save-temps".

#include 
int main()
{
  std::tr1::tuple t1( 1 );
  std::tr1::tuple t2( 1, 2 );
  if ( t1 < t2 ) {}
  if ( t1 == t2 ) {}
}

1$ g++ -v -save-temps tuples.cpp 
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
 /usr/lib/gcc/i486-linux-gnu/4.1.3/cc1plus -E -quiet -v -D_GNU_SOURCE
tuples.cpp -mtune=generic -fpch-preprocess -o tuples.ii
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.1.3
 /usr/include/c++/4.1.3/i486-linux-gnu
 /usr/include/c++/4.1.3/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.1.3/include
 /usr/include
End of search list.
 /usr/lib/gcc/i486-linux-gnu/4.1.3/cc1plus -fpreprocessed tuples.ii -quiet
-dumpbase tuples.cpp -mtune=generic -auxbase tuples -version -fstack-protector
-fstack-protector -o tuples.s
GNU C++ version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
(i486-linux-gnu)
compiled by GNU C version 4.1.3 20070929 (prerelease) (Ubuntu
4.1.2-16ubuntu2).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3cc47be363985179cfafdceddd0e8f5d
 as --traditional-format -V -Qy -o tuples.o tuples.s
GNU assembler version 2.18 (i486-linux-gnu) using BFD version (GNU Binutils for
Ubuntu) 2.18
 /usr/lib/gcc/i486-linux-gnu/4.1.3/collect2 --eh-frame-hdr -m elf_i386
--hash-style=both -dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crt1.o
/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crti.o
/usr/lib/gcc/i486-linux-gnu/4.1.3/crtbegin.o
-L/usr/lib/gcc/i486-linux-gnu/4.1.3 -L/usr/lib/gcc/i486-linux-gnu/4.1.3
-L/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib -L/lib/../lib
-L/usr/lib/../lib tuples.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/i486-linux-gnu/4.1.3/crtend.o
/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crtn.o


-- 
   Summary: Relational operators for  don't error on
different sized tuples
   Product: gcc
   Version: 4.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gryan at akoostix dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35480



[Bug c++/35480] Relational operators for don't error on different sized tuples

2008-03-06 Thread gryan at akoostix dot com


--- Comment #1 from gryan at akoostix dot com  2008-03-06 14:30 ---
Created an attachment (id=15269)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15269&action=view)
Preprocessed file

Preprocessed file output using the -save-temps flag.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35480



[Bug libstdc++/35480] Relational operators for don't error on different sized tuples

2008-03-06 Thread gryan at akoostix dot com


--- Comment #3 from gryan at akoostix dot com  2008-03-06 16:38 ---
I understand your concern here, which is why I wrote that I thought that it was
"implicit".

The standard says "where get(t) == get(u)" is a valid expression" only,
however; 6.1.3.4 says that get(t) is "ill formed if I is out of bounds."

In the original proposal Jarvi writes "An attempt to compare two tuples of
different lengths results in a compile time error." This is co-operated by
Becker in his TR-1 book, where we writes "... can be compared if they have the
same number of elements..." But the standard itself isn't so explicit.

To me, if get(t) fails to compile under the assumption of "ill formed", then
by the definitions of 6.1.3.5, get(t) == get(u) should also fail to
compile. Although it is not explicitly stated in N1836=05-0096.

At least that's my interpretation of "ill-formed." Are all ill-formed
expression compilation errors?

On an aside, it would certainly be useless to have something compile and run
with no side effects (as it does) when the construct is clearly erroneous.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35480