public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54376] New: incorrect complaint about redefinition
@ 2012-08-25 19:02 drepper.fsp at gmail dot com
  2012-08-25 19:45 ` [Bug c++/54376] " redi at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: drepper.fsp at gmail dot com @ 2012-08-25 19:02 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54376
           Summary: incorrect complaint about redefinition
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: drepper.fsp@gmail.com


At least I think this is a compiler problem.  I cannot see anything wrong in
the libstdc++ code or in my test code.

Compiling the following code with 4.7.0 or even the current trunk version of
the compiler will produce an error like this.  There is no double inclusion
problem and still the line with the redefinition is exactly the same as the
definition.

If you take out one of the two variable definitions and uses the error
disappears which indicates the problem is that the compiler doesn't distinguish
instantiations correctly.

The other pairs of instantiations also produce the same type of mistake.


In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.7.0/../../../../include/c++/4.7.0/random:50:0,
                 from r3.cc:3:
/usr/lib/gcc/x86_64-redhat-linux/4.7.0/../../../../include/c++/4.7.0/bits/random.h:
In instantiation of ‘class std::lognormal_distribution<double>’:
r3.cc:31:39:   required from here
/usr/lib/gcc/x86_64-redhat-linux/4.7.0/../../../../include/c++/4.7.0/bits/random.h:2279:9:
error: redefinition of ‘template<class _RealType1> bool std::operator==(const
std::lognormal_distribution<_RealType>&, const
std::lognormal_distribution<_RealType>&)’
/usr/lib/gcc/x86_64-redhat-linux/4.7.0/../../../../include/c++/4.7.0/bits/random.h:2279:9:
error: ‘template<class _RealType1> bool std::operator==(const
std::lognormal_distribution<_RealType>&, const
std::lognormal_distribution<_RealType>&)’ previously defined here



Source:

#include <functional>
#include <iostream>
#include <random>


template<class E, class D>
void measure(const char *name, size_t n, E &e, D &d)
{
  typename D::result_type arr[n];
  typename D::result_type s = 0;
  for (int tries = 0; tries < 100; ++tries)
    {
      e.seed(1234);

      for (size_t i = 0; i < n; ++i)
    arr[i] = d(e);

      for (size_t i = 0; i < n; ++i)
    s += arr[i];
    }

  std::cout << name << " " << n << " = " << " " << s << std::endl;
}


int
main(void)
{
  std::mt19937 e2;
  std::lognormal_distribution<float> d7;
  std::lognormal_distribution<double> d8;
  //std::gamma_distribution<float> d9;
  //std::gamma_distribution<double> d10;
  //std::chi_squared_distribution<float> d11;
  //std::chi_squared_distribution<double> d12;
  //std::fisher_f_distribution<float> d15;
  //std::fisher_f_distribution<double> d16;
  //std::student_t_distribution<float> d17;
  //std::student_t_distribution<double> d18;
  //std::binomial_distribution<uint32_t> d20;
  //std::binomial_distribution<uint64_t> d21;
  //std::negative_binomial_distribution<uint32_t> d24;
  //std::negative_binomial_distribution<uint64_t> d25;
  //std::poisson_distribution<uint32_t> d26;
  //std::poisson_distribution<uint64_t> d27;


  for (size_t n = 10; n < 100000; n *= 1.1)
    {
      measure("lognormal:32", n, e2, d7);
      measure("lognormal:64", n, e2, d8);
      //measure("gamma:32", n, e2, d9);
      //measure("gamma:64", n, e2, d10);
      //measure("chi_squared:32", n, e2, d11);
      //measure("chi_squared:64", n, e2, d12);
      //measure("fisher_f:32", n, e2, d15);
      //measure("fisher_f:64", n, e2, d16);
      //measure("student_t:32", n, e2, d17);
      //measure("student_t:64", n, e2, d18);
      //measure("binomial:32", n, e2, d20);
      //measure("binomial:64", n, e2, d21);
      //measure("negative_binomial:32", n, e2, d24);
      //measure("negative_binomial:64", n, e2, d25);
      //measure("poisson:32", n, e2, d26);
      //measure("poisson:64", n, e2, d27);
    }
}


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2012-09-06  9:29 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-25 19:02 [Bug c++/54376] New: incorrect complaint about redefinition drepper.fsp at gmail dot com
2012-08-25 19:45 ` [Bug c++/54376] " redi at gcc dot gnu.org
2012-08-25 19:50 ` redi at gcc dot gnu.org
2012-08-25 20:05 ` paolo.carlini at oracle dot com
2012-08-25 20:18 ` redi at gcc dot gnu.org
2012-08-25 20:25 ` paolo.carlini at oracle dot com
2012-08-25 20:31 ` daniel.kruegler at googlemail dot com
2012-08-25 20:34 ` redi at gcc dot gnu.org
2012-08-25 20:39 ` paolo.carlini at oracle dot com
2012-08-25 21:04 ` glisse at gcc dot gnu.org
2012-08-25 22:54 ` drepper.fsp at gmail dot com
2012-08-26  7:54 ` [Bug libstdc++/54376] " glisse at gcc dot gnu.org
2012-08-26  9:46 ` paolo.carlini at oracle dot com
2012-08-26 12:59 ` paolo.carlini at oracle dot com
2012-08-26 14:04 ` paolo.carlini at oracle dot com
2012-08-26 17:23 ` paolo at gcc dot gnu.org
2012-08-27 18:14 ` jason at gcc dot gnu.org
2012-08-27 20:40 ` paolo.carlini at oracle dot com
2012-09-06  9:27 ` paolo at gcc dot gnu.org
2012-09-06  9:28 ` paolo.carlini at oracle dot com
2012-09-06  9:29 ` paolo at gcc dot gnu.org

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).