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

joaquin at tid dot es gcc-bugzilla@gcc.gnu.org
Sun Mar 13 13:28:00 GMT 2005


This is happening in the compilation of boost::aligned_storage
(boost/aligned_storage.hpp) in the current CVS. 
The version of GCC used is 4.0.0 20050309 (prerelease)

I am sorry I can't provide a verified to fail snippet,
since I don't have access to that version of GCC. The
following is an untested attempt to reproduce the
problem in isolated code.

#include <cstddef>

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

int main()
{
  aligned_storage<1> as;
}

This produces the following:

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

which AFAICS is an invalid error.

-- 
           Summary: GCC fails to treat a valid constant expression as a
                    template argument
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: joaquin at tid dot es
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list