[Bug c++/20453] GCC fails to treat a valid constant expression as a template argument

joaquin at tid dot es gcc-bugzilla@gcc.gnu.org
Mon Mar 14 17:08:00 GMT 2005


------- Additional Comments From joaquin at tid dot es  2005-03-14 17:08 -------
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > I cannot reproduce it either with an obvious change to fix the missing
> > 
> > Too bad. Sorry for reporting this in such an imprecise
> > manner. The actual problem shows at Boost regression tests
> > 

OK, I've got a test case:

#include <cstddef>

template<
 std::size_t size_,
 std::size_t alignment_ = std::size_t(-1)>
struct aligned_storage
{
};

template<typename T>
struct foo
{
  aligned_storage<sizeof(T)> as;
};

int main()
{
  foo<double> f;
}

Fails with the following:

13: error: '(size_t)((-1))' is not a valid template argument for type 'unsigned 
int' because it is a non-constant expression

Regards,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


-- 


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



More information about the Gcc-bugs mailing list