LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


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

Rep: Reputation: Disabled

Quote:
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, 09:26 PM   #17
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
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 09:30 PM.
 
  


Reply


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 08:33 PM
list with dynamic array TurtleFace Programming 7 11-05-2006 07:58 PM
expanding dynamic array niteshadw Programming 6 06-26-2005 12:19 AM
More dynamic array problems PTBmilo Programming 5 03-14-2003 01:51 AM
dynamic array in class help PTBmilo Programming 6 03-09-2003 03:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:03 PM.

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