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

           Summary: [C++0x] ICE: in cxx_eval_constant_expression, at
                    cp/semantics.c:6686 on invalid code (+rejects valid)
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: zso...@seznam.cz


Testcase is similiar to PR46870:

-------- testcase.C --------
template < int > struct S
{
  void foo ()
  {
//    const int c = 0;
    const int b = c > c;
    S < b > ();
  }
};
----------------------------

Compiler output:
$ gcc testcase.C -std=c++0x
testcase.C: In member function 'void S<<anonymous> >::foo()':
testcase.C:6:19: error: 'c' was not declared in this scope
testcase.C:7:11: error: '(int)b' is not a valid template argument for type
'int' because it is a non-constant expression
testcase.C:7:11: error: the value of 'b' is not usable in a constant expression
testcase.C:7:11: internal compiler error: in cxx_eval_constant_expression, at
cp/semantics.c:6686
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Backtrace is quite long (44 callers)


When the commented code is uncommented, it seems gcc rejects valid code (comeau
online accepts it):
-------- testcase.C --------
template < int > struct S
{
  void foo ()
  {
    const int c = 0;
    const int b = c > c;
    S < b > ();
  }
};
----------------------------
$ gcc testcase.C -std=c++0x
testcase.C: In member function 'void S<<anonymous> >::foo()':
testcase.C:7:11: error: could not convert template argument 'b' to 'int'

Reply via email to