[Bug libstdc++/61041] New: Cannot create std::tr1::variate_generator from variate_generator::engine(); engine_value_type error

hstong at ca dot ibm.com gcc-bugzilla@gcc.gnu.org
Sat May 3 00:15:00 GMT 2014


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

            Bug ID: 61041
           Summary: Cannot create std::tr1::variate_generator from
                    variate_generator::engine(); engine_value_type error
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com

http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.tr1 shows
that support for ISO/IEC DTR 19768 subclause 5.1.3 is available in libstdc++.

It seems that engine_value_type in libstdc++ is not defined such that it
matches 5.1.3 paragraph 2 (assuming the DTR is close enough to the TR):
The template argument for the parameter Engine shall be of the form U, U&, or
U*, where U denotes a class that satisfies all the requirements of a uniform
random number generator. The member engine_value_type shall name U.

The following small client for <tr1/random> generates error messages showing
that the engine_value_type typedef is some specialization of
std::tr1::__detail::_Adaptor and not the corresponding "U" for U& =
::EngineType.

### SOURCE:> cat engine_value_type.cc
#include <tr1/random>

typedef std::tr1::linear_congruential<unsigned, 1, 0, 2048> &EngineType;
typedef std::tr1::uniform_int<unsigned> DistType;

std::tr1::variate_generator<EngineType, DistType>
getWithNewDist(std::tr1::variate_generator<EngineType, DistType> &orig,
               const DistType &newDist) {
   return std::tr1::variate_generator<EngineType, DistType>(orig.engine(),
newDist);
}


### COMPILER INVOCATION AND OUTPUT:> g++ engine_value_type.cc
engine_value_type.cc: In function
‘std::tr1::variate_generator<std::tr1::linear_congruential<unsigned int, 1u,
0u, 2048u>&, std::tr1::uniform_int<unsigned int> >
getWithNewDist(std::tr1::variate_generator<std::tr1::linear_congruential<unsigned
int, 1u, 0u, 2048u>&, std::tr1::uniform_int<unsigned int> >&, const
DistType&)’:
engine_value_type.cc:8:83: error: no matching function for call to
‘std::tr1::variate_generator<std::tr1::linear_congruential<unsigned int, 1u,
0u, 2048u>&, std::tr1::uniform_int<unsigned int>
>::variate_generator(std::tr1::variate_generator<std::tr1::linear_congruential<unsigned
int, 1u, 0u, 2048u>&, std::tr1::uniform_int<unsigned int>
>::engine_value_type&, const DistType&)’
    return std::tr1::variate_generator<EngineType, DistType>(orig.engine(),
newDist);
                                                                               
   ^
engine_value_type.cc:8:83: note: candidates are:
In file included from
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/tr1/random:47:0,
                 from engine_value_type.cc:1:
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/tr1/random.h:252:7: note:
std::tr1::variate_generator<_Engine,
_Dist>::variate_generator(std::tr1::variate_generator<_Engine,
_Dist>::engine_type, std::tr1::variate_generator<_Engine,
_Dist>::distribution_type) [with _Engine =
std::tr1::linear_congruential<unsigned int, 1u, 0u, 2048u>&; _Dist =
std::tr1::uniform_int<unsigned int>; std::tr1::variate_generator<_Engine,
_Dist>::engine_type = std::tr1::linear_congruential<unsigned int, 1u, 0u,
2048u>&; std::tr1::variate_generator<_Engine, _Dist>::distribution_type =
std::tr1::uniform_int<unsigned int>]
       variate_generator(engine_type __eng, distribution_type __dist)
       ^
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/tr1/random.h:252:7: note:   no
known conversion for argument 1 from
‘std::tr1::variate_generator<std::tr1::linear_congruential<unsigned int, 1u,
0u, 2048u>&, std::tr1::uniform_int<unsigned int> >::engine_value_type {aka
std::tr1::__detail::_Adaptor<std::tr1::linear_congruential<unsigned int, 1u,
0u, 2048u>&, std::tr1::uniform_int<unsigned int> >}’ to
‘std::tr1::variate_generator<std::tr1::linear_congruential<unsigned int, 1u,
0u, 2048u>&, std::tr1::uniform_int<unsigned int> >::engine_type {aka
std::tr1::linear_congruential<unsigned int, 1u, 0u, 2048u>&}’
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/tr1/random.h:228:11: note:
std::tr1::variate_generator<std::tr1::linear_congruential<unsigned int, 1u, 0u,
2048u>&, std::tr1::uniform_int<unsigned int> >::variate_generator(const
std::tr1::variate_generator<std::tr1::linear_congruential<unsigned int, 1u, 0u,
2048u>&, std::tr1::uniform_int<unsigned int> >&)
     class variate_generator
           ^
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/tr1/random.h:228:11: note:  
candidate expects 1 argument, 2 provided


### VERSION INFO:> g++ --version
g++ (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


More information about the Gcc-bugs mailing list