[Bug c++/53464] New: Invalid default value for non-type template parameter is accepted

2012-05-23 Thread sch...@uni-mainz.de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53464

 Bug #: 53464
   Summary: Invalid default value for non-type template parameter
is accepted
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: sch...@uni-mainz.de


Consider the following code:

template 
struct bar
{
static constexpr int get()
{
return value;
}
};

template 
struct foo
{
};

int main()
{
typedef foo> type;

return 0;
}

It should be rejected, since A::get() is not a "converted constant expression"
as discussed in http://stackoverflow.com/questions/10721130 . I tested this
with the GCC from svn.


[Bug libstdc++/63176] New: std::generate_canonical::digits> generates 1.0

2014-09-04 Thread sch...@uni-mainz.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63176

Bug ID: 63176
   Summary: std::generate_canonical::digits> generates 1.0
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: sch...@uni-mainz.de

std::generate_canonical can generate 1.0, which does not conform to the c++11
standard. On my box the following program yields "Bug!":

#include 
#include 
#include 

int main()
{
std::mt19937 rng;

std::seed_seq sequence{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
rng.seed(sequence);
rng.discard(12 * 629143 + 6);

float random = std::generate_canonical::digits>(rng);

if (random == 1.0f)
{
std::cout << "Bug!\n";
}

return 0;
}

See also
http://stackoverflow.com/questions/25668600/is-1-0-a-valid-random-number for a
longer discussion and analysis of the problem.

I first noticed this on my system GCC,

gcc (Gentoo 4.7.3-r1 p1.4, pie-0.5.5) 4.7.3
Copyright (C) 2012 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.

but I can reproduce the same behavior with a recent GCC from git:

gcc (GCC) 5.0.0 20140830 (experimental)
Copyright (C) 2014 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.

I used `c++ =std=c++11` to compile the program above.