public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: Omar Shaikh <omarshaikh71@yahoo.com> To: gcc-bugs@gcc.gnu.org Subject: g++ allows variable array creation Date: Mon, 19 Jan 2004 11:31:00 -0000 [thread overview] Message-ID: <20040119113123.19364.qmail@web20909.mail.yahoo.com> (raw) Dear All I found something in the GNU compiler that I am not sure is a bug or the latest change to the C++ standard. However, the same did not work in Microsoft C++ (v. 13.10.3077), the C++ compiler that comes with Microsoft .NET product. I ran this code on both Win32 and Linux platforms with full warnings on (-Wall). Surprisingly, there were no warnings either. The compiler that I used on Windows (XP): MinGW: c++ (GCC) 3.2.3 (mingw special 20030504-1) Compiler used on (Mandrake) Linux: g++ (GCC) 3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk) #include <iostream.h> class A { int v; public: A () { } void SetV (int nv) { v = nv; } int GetV () { return v; } }; int main () { A x; int i; cout << "Enter array size: "; cin >> i; x.SetV(i); const int m = x.GetV(); int arr[m]; // Works fine! cout << "Array size = " << sizeof(arr) << " bytes" << endl; return 0; } Here are two sample runs of the program. (Underscored text is user i/p.) Enter array size: _10_ Array size = 40 bytes Next run Enter array size: _25_ Array size = 100 bytes The code above works fine, though the array size can be decided during runtime. Please let me know if I am missing something. Thank you. Omar __________________________________ Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus
next reply other threads:[~2004-01-19 11:31 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-01-19 11:31 Omar Shaikh [this message] 2004-01-19 12:12 ` Andrew Pinski 2004-01-19 16:42 ` Gabriel Dos Reis
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040119113123.19364.qmail@web20909.mail.yahoo.com \ --to=omarshaikh71@yahoo.com \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).