public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/2362: boost: "gcc can't handle cv-qualified references"
@ 2001-03-23  7:46 schmid
  0 siblings, 0 replies; only message in thread
From: schmid @ 2001-03-23  7:46 UTC (permalink / raw)
  To: gcc-gnats

>Number:         2362
>Category:       c++
>Synopsis:       boost: "gcc can't handle cv-qualified references"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 23 07:46:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        3.0 20010321 (prerelease)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.2 #34 Sun Feb 25 20:03:34 CET 2001 i686 unknown
Architecture: i686
SuSE 7.1
Glibc 2.2
GNU ld version 2.11.90.0.1 (with BFD 2.11.90.0.1)	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
>Description:
The following code tc.C extracted from
type_traits/composite_traits_test.cpp from boost version 1_21_1 does not
produce the expected output when compiled by gcc. It seems that for const
references the wrong function is called. There is a comment in the
source code of composite_traits_test.cpp stating that g++ "can't
handle cv-qualified references". 
>How-To-Repeat:
Source code tc.C

//  (C) Copyright John Maddock 2000. Permission to copy, use, modify, sell and   
//  distribute this software is granted provided this copyright notice appears
//  in all copies. This software is provided "as is" without express or implied
//  warranty, and with no claim as to its suitability for any purpose.

extern "C" int printf (const char *, ...);

namespace boost{

template <typename T> struct is_reference 
{ static const bool value = false; };
template <typename T> struct is_reference<T&> 
{ static const bool value = true; };

} // namespace boost

unsigned int failures = 0;
unsigned int test_count = 0;
unsigned int expected_failures = 1; // Gcc can't handle cv-qualified references

int check_result()
{
    printf("%i tests completed, %i failures found, %i failures expected from this compiler.\n", test_count, failures, expected_failures);

    return (failures == expected_failures) ? 0 : failures;
}

template <bool>
struct checker
{
   static void check(bool, bool, const char*){ ++test_count; }
};

template <>
struct checker<false>
{
   static void check(bool o, bool n, const char* name)
   {
      ++test_count;
      ++failures;

        printf("checking value of %s...failed\n", name);
        printf("\tfound: %i expected %i\n", n, o);  

   }
};

#define value_test(v, x) checker<(v == x)>::check(v, x, #x);

typedef int& r_type;
typedef const r_type cr_type;

int main()
{
   value_test(true, boost::is_reference<r_type>::value)
   value_test(true, boost::is_reference<cr_type>::value)
   return check_result();
}

Compiling tc.C
g++ -v -o tc tc.C -W -Wall -save-temps
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
gcc version 3.0 20010321 (prerelease)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/cpp0 -lang-c++ -D_GNU_SOURCE -D__GNUG__=3 -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tc.C tc.ii
GNU CPP version 3.0 20010321 (prerelease) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -fpreprocessed tc.ii -quiet -dumpbase tc.C -W -Wall -version -o tc.s
GNU CPP version 3.0 20010321 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 20010321 (prerelease) (i686-pc-linux-gnu)
	compiled by GNU C version 3.0 20010321 (prerelease).
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o tc.o tc.s
GNU assembler version 2.11.90.0.1 (i686-pc-linux-gnu) using BFD version 2.11.90.0.1
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o tc /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/crtbegin.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/../../../../i686-pc-linux-gnu/lib -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/../../.. tc.o -lstdc++ -lm -lgcc_s -lc -lgcc_s /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/crtend.o /usr/lib/crtn.o

Running the programm tc
peter@kiste:~ > ./tc
checking value of boost::is_reference<cr_type>::value...failed
	found: 0 expected 1
2 tests completed, 1 failures found, 1 failures expected from this compiler.

Preprocessed source code tc.ii

# 6 "tc.C"
extern "C" int printf (const char *, ...);

namespace boost{

template <typename T> struct is_reference
{ static const bool value = false; };
template <typename T> struct is_reference<T&>
{ static const bool value = true; };

}

unsigned int failures = 0;
unsigned int test_count = 0;
unsigned int expected_failures = 1;

int check_result()
{
    printf("%i tests completed, %i failures found, %i failures expected from this compiler.\n", test_count, failures, expected_failures);

    return (failures == expected_failures) ? 0 : failures;
}

template <bool>
struct checker
{
   static void check(bool, bool, const char*){ ++test_count; }
};

template <>
struct checker<false>
{
   static void check(bool o, bool n, const char* name)
   {
      ++test_count;
      ++failures;

        printf("checking value of %s...failed\n", name);
        printf("\tfound: %i expected %i\n", n, o);

   }
};



typedef int& r_type;
typedef const r_type cr_type;

int main()
{
   checker<(true == boost::is_reference<r_type>::value)>::check(true, boost::is_reference<r_type>::value, "boost::is_reference<r_type>::value");
   checker<(true == boost::is_reference<cr_type>::value)>::check(true, boost::is_reference<cr_type>::value, "boost::is_reference<cr_type>::value");
   return check_result();
}

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-03-23  7:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-23  7:46 c++/2362: boost: "gcc can't handle cv-qualified references" schmid

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).