public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35125]  New: Violating standards
@ 2008-02-07 13:12 amitondemand at gmail dot com
  2008-02-07 14:17 ` [Bug c++/35125] " rguenth at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: amitondemand at gmail dot com @ 2008-02-07 13:12 UTC (permalink / raw)
  To: gcc-bugs

i compiled the following code on  
"Red Hat Linux Enterprise AS Realease 4
 Kernel 2.6.9-5 Elsmp"
and the code was compiled successfully and was running.


//I dont know how this code is working.

#include<iostream>
using namespace std;

int main()
{
    int size;
    int arr[size];

    cout<<"Enter size of array: ";
    cin>>size;


    cout<<"Enter values: \n";
    for(int i=0; i< size; i++)
        cin>>arr[i];

    cout<<"Outputting values: \n";
    for(int i=0; i< size; i++)
        cout<<arr[i]<<endl;

    return 0;
}

how the size is being determined by the compiler, when it is not constant? Also
the .c version of above code is compiling and running.

regards,
Amit Singh


-- 
           Summary: Violating standards
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amitondemand at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/35125] Violating standards
  2008-02-07 13:12 [Bug c++/35125] New: Violating standards amitondemand at gmail dot com
@ 2008-02-07 14:17 ` rguenth at gcc dot gnu dot org
  2008-02-07 15:23 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-07 14:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-02-07 14:16 -------
This code doesn't work reliably.  Change it to

int main()
{
    int size;


    cout<<"Enter size of array: ";
    cin>>size;

    int arr[size];
...


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/35125] Violating standards
  2008-02-07 13:12 [Bug c++/35125] New: Violating standards amitondemand at gmail dot com
  2008-02-07 14:17 ` [Bug c++/35125] " rguenth at gcc dot gnu dot org
@ 2008-02-07 15:23 ` pinskia at gcc dot gnu dot org
  2008-02-07 16:07 ` manu at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-07 15:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2008-02-07 15:22 -------
VLA in C++ is an extension, if you use -pedantic, you will get an error.

Also VLA uses the value at the time at definition and no other value after
wards.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/35125] Violating standards
  2008-02-07 13:12 [Bug c++/35125] New: Violating standards amitondemand at gmail dot com
  2008-02-07 14:17 ` [Bug c++/35125] " rguenth at gcc dot gnu dot org
  2008-02-07 15:23 ` pinskia at gcc dot gnu dot org
@ 2008-02-07 16:07 ` manu at gcc dot gnu dot org
  2008-02-08  7:00 ` amitondemand at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-02-07 16:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from manu at gcc dot gnu dot org  2008-02-07 16:07 -------
Also, you should get a warning when using -Wuninitialized -O (or -Wall -O).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/35125] Violating standards
  2008-02-07 13:12 [Bug c++/35125] New: Violating standards amitondemand at gmail dot com
                   ` (2 preceding siblings ...)
  2008-02-07 16:07 ` manu at gcc dot gnu dot org
@ 2008-02-08  7:00 ` amitondemand at gmail dot com
  2008-02-08  7:21 ` amitondemand at gmail dot com
  2008-02-08  9:02 ` manu at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: amitondemand at gmail dot com @ 2008-02-08  7:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from amitondemand at gmail dot com  2008-02-08 06:59 -------
i think this should not work. you should get an error that array size must be
constant.

(In reply to comment #1)
> This code doesn't work reliably.  Change it to
> int main()
> {
>     int size;
>     cout<<"Enter size of array: ";
>     cin>>size;
>     int arr[size];
> ...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/35125] Violating standards
  2008-02-07 13:12 [Bug c++/35125] New: Violating standards amitondemand at gmail dot com
                   ` (3 preceding siblings ...)
  2008-02-08  7:00 ` amitondemand at gmail dot com
@ 2008-02-08  7:21 ` amitondemand at gmail dot com
  2008-02-08  9:02 ` manu at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: amitondemand at gmail dot com @ 2008-02-08  7:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from amitondemand at gmail dot com  2008-02-08 07:20 -------
As i know C++ doesn't support VLA. Please update me if i m wrong.

(In reply to comment #2)
> VLA in C++ is an extension, if you use -pedantic, you will get an error.
> Also VLA uses the value at the time at definition and no other value after
> wards.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/35125] Violating standards
  2008-02-07 13:12 [Bug c++/35125] New: Violating standards amitondemand at gmail dot com
                   ` (4 preceding siblings ...)
  2008-02-08  7:21 ` amitondemand at gmail dot com
@ 2008-02-08  9:02 ` manu at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-02-08  9:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from manu at gcc dot gnu dot org  2008-02-08 09:01 -------
(In reply to comment #5)
> As i know C++ doesn't support VLA. Please update me if i m wrong.

That is why it is an extension. There are many things that GCC supports and ISO
C++ doesn't. Read the GCC's manual for information about extensions [1] and
about -pedantic [2].

[1] http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html#C-Extensions
[2] http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options

This is not a forum, if you need help using GCC, please ask in
gcc-help@gcc.gnu.org and not here. Thanks.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-02-08  9:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-07 13:12 [Bug c++/35125] New: Violating standards amitondemand at gmail dot com
2008-02-07 14:17 ` [Bug c++/35125] " rguenth at gcc dot gnu dot org
2008-02-07 15:23 ` pinskia at gcc dot gnu dot org
2008-02-07 16:07 ` manu at gcc dot gnu dot org
2008-02-08  7:00 ` amitondemand at gmail dot com
2008-02-08  7:21 ` amitondemand at gmail dot com
2008-02-08  9:02 ` manu at gcc dot gnu dot org

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).