Bug 43913 - error: ‘<expression error>’ is not a valid template argument for type ‘int’ because it is a non-constant expression
Summary: error: ‘<expression error>’ is not a valid template argument for type ‘int’ b...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2010-04-27 20:46 UTC by Manuel López-Ibáñez
Modified: 2011-10-09 16:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel López-Ibáñez 2010-04-27 20:46:05 UTC
/home/manuel/src/test/gcc/testsuite/g++.dg/template/recurse3.C: In instantiation of ‘const int Y<1000>::value’:
/home/manuel/src/test/gcc/testsuite/g++.dg/template/recurse3.C:17:17:   instantiated from here
/home/manuel/src/test/gcc/testsuite/g++.dg/template/recurse3.C:13:46: error: ‘<expression error>’ is not a valid template argument for type ‘int’ because it is a non-constant expression

Testcase is related to PR9335.

// PR c++/9335
// We should not see an error about non-constant initialization.
// { dg-do compile }
// { dg-options "-ftemplate-depth-15" }
template<int N> struct Y;
template <int N> struct X {
  static const int value = X<Y<N-1>::value>::value;
  // { dg-message "skipping \d instantiation contexts" "" { target *-*-* } 0 }
  // { dg-bogus "expression error" "" { xfail *-*-* } 0 }
};

template <int N> struct Y {
  static const int value = Y<X<N-1>::value>::value;  // { dg-error "incomplete type" }

};

template struct Y<1000>;
Comment 1 Paolo Carlini 2011-10-09 16:08:23 UTC
This is fixed in 4.6.x.