Index: include/bits/random.tcc
===================================================================
--- include/bits/random.tcc	(revision 165419)
+++ include/bits/random.tcc	(working copy)
@@ -2217,7 +2217,6 @@
       if (_M_prob.size() < 2)
 	{
 	  _M_prob.clear();
-	  _M_prob.push_back(1.0);
 	  return;
 	}
 
@@ -2257,6 +2256,9 @@
       operator()(_UniformRandomNumberGenerator& __urng,
 		 const param_type& __param)
       {
+	if (__param._M_cp.empty())
+	  return result_type(0);
+
 	__detail::_Adaptor<_UniformRandomNumberGenerator, double>
 	  __aurng(__urng);
 
@@ -2330,16 +2332,13 @@
     piecewise_constant_distribution<_RealType>::param_type::
     _M_initialize()
     {
-      if (_M_int.size() < 2)
+      if (_M_int.size() < 2
+	  || (_M_int.size() == 2
+	      && _M_int[0] == _RealType(0)
+	      && _M_int[1] == _RealType(1)))
 	{
 	  _M_int.clear();
-	  _M_int.reserve(2);
-	  _M_int.push_back(_RealType(0));
-	  _M_int.push_back(_RealType(1));
-
 	  _M_den.clear();
-	  _M_den.push_back(1.0);
-
 	  return;
 	}
 
@@ -2433,6 +2432,9 @@
 	  __aurng(__urng);
 
 	const double __p = __aurng();
+	if (__param._M_cp.empty())
+	  return __p;
+
 	auto __pos = std::lower_bound(__param._M_cp.begin(),
 				      __param._M_cp.end(), __p);
 	const size_t __i = __pos - __param._M_cp.begin();
@@ -2519,18 +2521,14 @@
     piecewise_linear_distribution<_RealType>::param_type::
     _M_initialize()
     {
-      if (_M_int.size() < 2)
+      if (_M_int.size() < 2
+	  || (_M_int.size() == 2
+	      && _M_int[0] == _RealType(0)
+	      && _M_int[1] == _RealType(1)
+	      && _M_den[0] == _M_den[1]))
 	{
 	  _M_int.clear();
-	  _M_int.reserve(2);
-	  _M_int.push_back(_RealType(0));
-	  _M_int.push_back(_RealType(1));
-
 	  _M_den.clear();
-	  _M_den.reserve(2);
-	  _M_den.push_back(1.0);
-	  _M_den.push_back(1.0);
-
 	  return;
 	}
 
@@ -2623,7 +2621,7 @@
 	  __aurng(__urng);
 
 	const double __p = __aurng();
-	if (__param._M_m.empty())
+	if (__param._M_cp.empty())
 	  return __p;
 
 	auto __pos = std::lower_bound(__param._M_cp.begin(),
Index: include/bits/random.h
===================================================================
--- include/bits/random.h	(revision 165419)
+++ include/bits/random.h	(working copy)
@@ -4697,7 +4697,7 @@
 	friend class discrete_distribution<_IntType>;
 
 	param_type()
-	: _M_prob(1, 1.0), _M_cp()
+	: _M_prob(), _M_cp()
 	{ }
 
 	template<typename _InputIterator>
@@ -4720,7 +4720,7 @@
 
 	std::vector<double>
 	probabilities() const
-	{ return _M_prob; }
+	{ return _M_prob.empty() ? std::vector<double>(1, 1.0) : _M_prob; }
 
 	friend bool
 	operator==(const param_type& __p1, const param_type& __p2)
@@ -4771,7 +4771,10 @@
        */
       std::vector<double>
       probabilities() const
-      { return _M_param.probabilities(); }
+      {
+	return _M_param._M_prob.empty()
+	  ? std::vector<double>(1, 1.0) : _M_param._M_prob;
+      }
 
       /**
        * @brief Returns the parameter set of the distribution.
@@ -4800,7 +4803,10 @@
        */
       result_type
       max() const
-      { return this->_M_param._M_prob.size() - 1; }
+      {
+	return _M_param._M_prob.empty()
+	  ? result_type(0) : result_type(_M_param._M_prob.size() - 1);
+      }
 
       /**
        * @brief Generating functions.
@@ -4893,8 +4899,8 @@
 	friend class piecewise_constant_distribution<_RealType>;
 
 	param_type()
-	: _M_int(2), _M_den(1, 1.0), _M_cp()
-	{ _M_int[1] = _RealType(1); }
+	: _M_int(), _M_den(), _M_cp()
+	{ }
 
 	template<typename _InputIteratorB, typename _InputIteratorW>
 	  param_type(_InputIteratorB __bfirst,
@@ -4914,11 +4920,20 @@
 
 	std::vector<_RealType>
 	intervals() const
-	{ return _M_int; }
+	{
+	  if (_M_int.empty())
+	    {
+	      std::vector<_RealType> __tmp(2);
+	      __tmp[1] = _RealType(1);
+	      return __tmp;
+	    }
+	  else
+	    return _M_int;
+	}
 
 	std::vector<double>
 	densities() const
-	{ return _M_den; }
+	{ return _M_den.empty() ? std::vector<double>(1, 1.0) : _M_den; }
 
 	friend bool
 	operator==(const param_type& __p1, const param_type& __p2)
@@ -4975,14 +4990,26 @@
        */
       std::vector<_RealType>
       intervals() const
-      { return _M_param.intervals(); }
+      {
+	if (_M_param._M_int.empty())
+	  {
+	    std::vector<_RealType> __tmp(2);
+	    __tmp[1] = _RealType(1);
+	    return __tmp;
+	  }
+	else
+	  return _M_param._M_int;
+      }
 
       /**
        * @brief Returns a vector of the probability densities.
        */
       std::vector<double>
       densities() const
-      { return _M_param.densities(); }
+      {
+	return _M_param._M_den.empty()
+	  ? std::vector<double>(1, 1.0) : _M_param._M_den;
+      }
 
       /**
        * @brief Returns the parameter set of the distribution.
@@ -5004,14 +5031,20 @@
        */
       result_type
       min() const
-      { return this->_M_param._M_int.front(); }
+      {
+	return _M_param._M_int.empty()
+	  ? result_type(0) : _M_param._M_int.front();
+      }
 
       /**
        * @brief Returns the least upper bound value of the distribution.
        */
       result_type
       max() const
-      { return this->_M_param._M_int.back(); }
+      {
+	return _M_param._M_int.empty()
+	  ? result_type(1) : _M_param._M_int.back();
+      }
 
       /**
        * @brief Generating functions.
@@ -5105,8 +5138,8 @@
 	friend class piecewise_linear_distribution<_RealType>;
 
 	param_type()
-	: _M_int(2), _M_den(2, 1.0), _M_cp(), _M_m()
-	{ _M_int[1] = _RealType(1); }
+	: _M_int(), _M_den(), _M_cp(), _M_m()
+	{ }
 
 	template<typename _InputIteratorB, typename _InputIteratorW>
 	  param_type(_InputIteratorB __bfirst,
@@ -5126,11 +5159,20 @@
 
 	std::vector<_RealType>
 	intervals() const
-	{ return _M_int; }
+	{
+	  if (_M_int.empty())
+	    {
+	      std::vector<_RealType> __tmp(2);
+	      __tmp[1] = _RealType(1);
+	      return __tmp;
+	    }
+	  else
+	    return _M_int;
+	}
 
 	std::vector<double>
 	densities() const
-	{ return _M_den; }
+	{ return _M_den.empty() ? std::vector<double>(2, 1.0) : _M_den; }
 
 	friend bool
 	operator==(const param_type& __p1, const param_type& __p2)
@@ -5189,7 +5231,16 @@
        */
       std::vector<_RealType>
       intervals() const
-      { return _M_param.intervals(); }
+      {
+	if (_M_param._M_int.empty())
+	  {
+	    std::vector<_RealType> __tmp(2);
+	    __tmp[1] = _RealType(1);
+	    return __tmp;
+	  }
+	else
+	  return _M_param._M_int;
+      }
 
       /**
        * @brief Return a vector of the probability densities of the
@@ -5197,7 +5248,10 @@
        */
       std::vector<double>
       densities() const
-      { return _M_param.densities(); }
+      {
+	return _M_param._M_den.empty()
+	  ? std::vector<double>(2, 1.0) : _M_param._M_den;
+      }
 
       /**
        * @brief Returns the parameter set of the distribution.
@@ -5219,14 +5273,20 @@
        */
       result_type
       min() const
-      { return this->_M_param._M_int.front(); }
+      {
+	return _M_param._M_int.empty()
+	  ? result_type(0) : _M_param._M_int.front();
+      }
 
       /**
        * @brief Returns the least upper bound value of the distribution.
        */
       result_type
       max() const
-      { return this->_M_param._M_int.back(); }
+      {
+	return _M_param._M_int.empty()
+	  ? result_type(1) : _M_param._M_int.back();
+      }
 
       /**
        * @brief Generating functions.
Index: testsuite/26_numerics/random/piecewise_constant_distribution/operators/call-default.cc
===================================================================
--- testsuite/26_numerics/random/piecewise_constant_distribution/operators/call-default.cc	(revision 0)
+++ testsuite/26_numerics/random/piecewise_constant_distribution/operators/call-default.cc	(revision 0)
@@ -0,0 +1,41 @@
+// { dg-options "-std=c++0x" }
+// { dg-require-cstdint "" }
+//
+// 2010-10-13  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 26.5.8.5.2 Class template piecewise_constant_distribution
+//   [rand.dist.samp.pconst]
+
+#include <random>
+
+void
+test01()
+{
+  std::piecewise_constant_distribution<> u;
+  std::minstd_rand0 rng;
+
+  u(rng);
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
Index: testsuite/26_numerics/random/discrete_distribution/operators/call-default.cc
===================================================================
--- testsuite/26_numerics/random/discrete_distribution/operators/call-default.cc	(revision 0)
+++ testsuite/26_numerics/random/discrete_distribution/operators/call-default.cc	(revision 0)
@@ -0,0 +1,41 @@
+// { dg-options "-std=c++0x" }
+// { dg-require-cstdint "" }
+//
+// 2010-10-13  Paolo Carlini  <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 26.5.8.5.1 Class template discrete_distribution
+//   [rand.dist.samp.discrete]
+
+#include <random>
+
+void
+test01()
+{
+  std::discrete_distribution<> u;
+  std::minstd_rand0 rng;
+
+  u(rng);
+}
+
+int main()
+{
+  test01();
+  return 0;
+}



