Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-19-2009, 08:10 PM   #16
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled

Originally Posted by ErV View Post
Well, it is bad, because it shouldn't do this. I'd go as far as to call this a flaw.
You think that's bad, try typing in -128 when it prompts you (the one I posted.) Do yourself a favor and send the destructor output to stdout and run it twice: once without redirecting, then with redirecting standard output. You'll see in the first run that the destructor is called an absurd number of times, yet the second run shows a stack offset of -312 (on my system.) What sort of flaw causes the allocation of -128*3 objects, then destructs them infinitely?
Kevin Barry
Old 03-19-2009, 08:26 PM   #17
Senior Member
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Originally Posted by johnsfine View Post
In my opinion, the lack of this feature in the standard is a flaw in the standard.
This is matter of taste.
This feature looks wrong to me, because for me array is a solid continuous block of memory which might be inlined into code segment (instead of stack segment) during compile time. I suppose this extension won't work on static or global variables, right?

Adding ability to use variable as array size turns array into ugly cross-breed between memory block and a vector class, with worst features of both. First, I suppose you are aware what happens when you attempt to allocate more than 8megabytes on stack (which is possible). Second, if I can use variable to intialize that array, why can't I resize it or get its' length during program run? Doesn't make any sense to me. Third, it is feature of interpreted langauges where array is not a continuos memory block, but a class. I'm not sure why it should be included into standard C++ where one of the goals was to provide low-level functions. Especially when there is already std::vector around.

This is why I think this misfeature shouldn't exist in language. Language should be solid and logically built, without "quick and dirty" hacks like this one.

P.S. I have nothing else to tell and I'm not going to discuss this further.

Last edited by ErV; 03-19-2009 at 08:30 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Array Sizes JMJ_coder Programming 8 03-05-2008 07:33 PM
list with dynamic array TurtleFace Programming 7 11-05-2006 06:58 PM
expanding dynamic array niteshadw Programming 6 06-25-2005 11:19 PM
More dynamic array problems PTBmilo Programming 5 03-14-2003 12:51 AM
dynamic array in class help PTBmilo Programming 6 03-09-2003 02:35 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration