Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > size of array i...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 15 Topic 43846 of 48022
Post > Topic >>

size of array is not an integral constant-expression

by johnehein@[EMAIL PROTECTED] Mar 12, 2008 at 01:09 PM

#include <vector>
using namespace std;

template <typename Iter>
int
foo(Iter first, Iter last, int nn)
{
 const size_t n = last - first;
 double buf[n];
 return 0;
}

int
main(int argc, char **argv)
{
 vector<double> x;
 foo(x.begin(), x.end(), argc);
 return 0;
}

foo.cc:17:   instantiated from here
foo.cc:9: error: size of array is not an integral constant-expression

g++ 4.2.1

Is this error specific to g++ 4.x?  g++ 3.6.4 and g++ 2.9.5 have no
problems with it, but that doesn't mean they are right.  Is there some
reason to expect this to fail.

There are a few interesting workarounds that point to this being
unexpected behavior... I'll post those next.
 




 15 Posts in Topic:
size of array is not an integral constant-expression
johnehein@[EMAIL PROTECTE  2008-03-12 13:09:37 
Re: size of array is not an integral constant-expression
Ian Collins <ian-news@  2008-03-13 09:19:43 
Re: size of array is not an integral constant-expression
"Victor Bazarov"  2008-03-12 16:22:37 
Re: size of array is not an integral constant-expression
Vidar Hasfjord <vattil  2008-03-12 14:08:42 
Re: size of array is not an integral constant-expression
johnehein@[EMAIL PROTECTE  2008-03-12 16:45:05 
Re: size of array is not an integral constant-expression
Ian Collins <ian-news@  2008-03-13 12:57:27 
Re: size of array is not an integral constant-expression
johnehein@[EMAIL PROTECTE  2008-03-12 16:56:49 
Re: size of array is not an integral constant-expression
James Kanze <james.kan  2008-03-13 02:23:10 
Re: size of array is not an integral constant-expression
James Kanze <james.kan  2008-03-13 02:32:15 
Re: size of array is not an integral constant-expression
"Default User"   2008-03-13 17:45:57 
Re: size of array is not an integral constant-expression
Ron Natalie <ron@[EMAI  2008-03-15 11:08:12 
Re: size of array is not an integral constant-expression
James Kanze <james.kan  2008-03-16 02:58:50 
Re: size of array is not an integral constant-expression
Vidar Hasfjord <vattil  2008-03-18 09:57:08 
Re: size of array is not an integral constant-expression
Jeff Schwab <jeff@[EMA  2008-03-18 10:13:50 
Re: size of array is not an integral constant-expression
Ian Collins <ian-news@  2008-03-19 06:59:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:22:08 CDT 2008.