This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/10075: g++ 3.2.2 's const array problem.


>Number:         10075
>Category:       c++
>Synopsis:       g++ 3.2.2 's const array problem.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 14 07:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Lee, Kuk hyun
>Release:        Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/specs
>Organization:
>Environment:
Pentium3-800, RedHat Linux 8.0
>Description:
below code..

    char* const a = "First";
    *(a+1)='O';   -------------------- segment fault 
    printf("%s\n", a);

that must be running in standard c++.
and I found that's not error in gdb.

[errai]$ gdb ./const
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) break 4
Breakpoint 1 at 0x8048398: file const.cc, line 4.
(gdb) run
Starting program: /home/errai/test/const 

Breakpoint 1, main () at const.cc:4
4               char* const a = "First";
(gdb) n
5           *(a+1)='O';
(gdb) n
6           printf("%s\n", a);
(gdb) n
FOrst         ------------------------- not error
7       }
(gdb) n
0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6
(gdb) n
Single stepping until exit from function __libc_start_main, 
which has no line number information.

Program
(gdb)

>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="const.cc"
Content-Disposition: inline; filename="const.cc"

#include <stdio.h>

int main() {
	char* const a = "First";
    *(a+1)='O';
    printf("%s\n", a);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]