public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument
@ 2005-03-13 13:28 joaquin at tid dot es
  2005-03-13 13:43 ` [Bug c++/20453] " falk at debian dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: joaquin at tid dot es @ 2005-03-13 13:28 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug c++/20453] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
@ 2005-03-13 13:43 ` falk at debian dot org
  2005-03-13 14:31 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: falk at debian dot org @ 2005-03-13 13:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2005-03-13 13:42 -------
(In reply to comment #0)

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

I cannot reproduce the error with this code. Please provide a working test
case.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug c++/20453] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
  2005-03-13 13:43 ` [Bug c++/20453] " falk at debian dot org
@ 2005-03-13 14:31 ` pinskia at gcc dot gnu dot org
  2005-03-13 15:05 ` joaquin at tid dot es
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-13 14:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-13 14:30 -------
I cannot reproduce it either with an obvious change to fix the missing >:
#include <cstddef>

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

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

-- 


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


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

* [Bug c++/20453] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
  2005-03-13 13:43 ` [Bug c++/20453] " falk at debian dot org
  2005-03-13 14:31 ` pinskia at gcc dot gnu dot org
@ 2005-03-13 15:05 ` joaquin at tid dot es
  2005-03-13 15:09 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: joaquin at tid dot es @ 2005-03-13 15:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From joaquin at tid dot es  2005-03-13 15:05 -------
(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

http://tinyurl.com/4hxy5

I'll try to isolate it into a snippet amenable to study,
as soon as I find someone with access to that version of
the compiler

-- 


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


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

* [Bug c++/20453] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
                   ` (2 preceding siblings ...)
  2005-03-13 15:05 ` joaquin at tid dot es
@ 2005-03-13 15:09 ` pinskia at gcc dot gnu dot org
  2005-03-14 17:08 ` joaquin at tid dot es
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-13 15:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-13 15:09 -------
(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
> 
> http://tinyurl.com/4hxy5

Maybe this already been fixed.

-- 


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


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

* [Bug c++/20453] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
                   ` (3 preceding siblings ...)
  2005-03-13 15:09 ` pinskia at gcc dot gnu dot org
@ 2005-03-14 17:08 ` joaquin at tid dot es
  2005-03-14 17:11 ` [Bug c++/20453] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: joaquin at tid dot es @ 2005-03-14 17:08 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 915 bytes --]


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


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

* [Bug c++/20453] [4.0/4.1 Regression] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
                   ` (4 preceding siblings ...)
  2005-03-14 17:08 ` joaquin at tid dot es
@ 2005-03-14 17:11 ` pinskia at gcc dot gnu dot org
  2005-03-17 14:57 ` nathan at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-14 17:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-14 17:11 -------
Confirmed, this worked with 4.0.0 20050225 which means it started to fail after the branch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |critical
             Status|WAITING                     |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2005-03-14 17:11:31
               date|                            |
            Summary|GCC fails to treat a valid  |[4.0/4.1 Regression] GCC
                   |constant expression as a    |fails to treat a valid
                   |template argument           |constant expression as a
                   |                            |template argument
   Target Milestone|---                         |4.0.0


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


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

* [Bug c++/20453] [4.0/4.1 Regression] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
                   ` (5 preceding siblings ...)
  2005-03-14 17:11 ` [Bug c++/20453] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-03-17 14:57 ` nathan at gcc dot gnu dot org
  2005-03-17 15:38 ` [Bug c++/20453] [4.1 " pinskia at gcc dot gnu dot org
  2005-03-17 16:09 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu dot org @ 2005-03-17 14:57 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |nathan at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-03-14 17:11:31         |2005-03-17 14:53:18
               date|                            |


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


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

* [Bug c++/20453] [4.1 Regression] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
                   ` (6 preceding siblings ...)
  2005-03-17 14:57 ` nathan at gcc dot gnu dot org
@ 2005-03-17 15:38 ` pinskia at gcc dot gnu dot org
  2005-03-17 16:09 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-17 15:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-17 15:36 -------
(In reply to comment #6)
> Confirmed, this worked with 4.0.0 20050225 which means it started to fail after the branch.
Also it worked with the mainline with 20050306.
And also on the 4.0 branch, but it is still broken on the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.0/4.1 Regression] GCC    |[4.1 Regression] GCC fails
                   |fails to treat a valid      |to treat a valid constant
                   |constant expression as a    |expression as a template
                   |template argument           |argument
   Target Milestone|4.0.0                       |4.1.0


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


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

* [Bug c++/20453] [4.1 Regression] GCC fails to treat a valid constant expression as a template argument
  2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
                   ` (7 preceding siblings ...)
  2005-03-17 15:38 ` [Bug c++/20453] [4.1 " pinskia at gcc dot gnu dot org
@ 2005-03-17 16:09 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-17 16:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-17 16:09 -------
This is also fixed on the mainline.
It was fixed by:
2005-03-17  Nathan Sidwell  <nathan@codesourcery.com>

        PR c++/20186
        * pt.c (contains_dependent_cast_p): Remove.
        (fold_non_dependent_expr): Don't use it.
        (value_dependent_expression_p): Use a switch statement.
        reference_exprs can be dependent.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2005-03-17 16:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-13 13:28 [Bug c++/20453] New: GCC fails to treat a valid constant expression as a template argument joaquin at tid dot es
2005-03-13 13:43 ` [Bug c++/20453] " falk at debian dot org
2005-03-13 14:31 ` pinskia at gcc dot gnu dot org
2005-03-13 15:05 ` joaquin at tid dot es
2005-03-13 15:09 ` pinskia at gcc dot gnu dot org
2005-03-14 17:08 ` joaquin at tid dot es
2005-03-14 17:11 ` [Bug c++/20453] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-03-17 14:57 ` nathan at gcc dot gnu dot org
2005-03-17 15:38 ` [Bug c++/20453] [4.1 " pinskia at gcc dot gnu dot org
2005-03-17 16:09 ` pinskia at gcc dot gnu dot 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).