This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34362] New: Segmentation fault while using array of character pointers.
- From: "stevekoe at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Dec 2007 15:59:45 -0000
- Subject: [Bug c++/34362] New: Segmentation fault while using array of character pointers.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code produces segmentation fault at runtime.
-----------------------------CODE---------------------------------------------
#include <stdio.h>
#include <string.h>
main()
{
char * strArray[2];
printf("Enter 1:");
scanf("%s",strArray[0]);
printf("Enter 2:");
scanf("%s",strArray[1]);
}
However the following code does not,
-----------------------------CODE---------------------------------------------
#include <stdio.h>
#include <string.h>
main()
{
char * strArray[2];
printf("Enter 1:");
scanf("%s",strArray[0]);
printf("Enter 2:");
scanf("%s",strArray[1]);
int x = 0;
}
-----------------------------ERROR--------------------------------------------
Enter 1:hello
15669: symbol=__cxa_finalize; lookup in file=./stringEx1.s
15669: symbol=__cxa_finalize; lookup in file=/usr/lib/libstdc++.so.6
15669: symbol=__cxa_finalize; lookup in
file=/lib/tls/i686/cmov/libm.so.6
15669: symbol=__cxa_finalize; lookup in file=/lib/libgcc_s.so.1
15669: symbol=__cxa_finalize; lookup in
file=/lib/tls/i686/cmov/libc.so.6
Segmentation fault
--
Summary: Segmentation fault while using array of character
pointers.
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: stevekoe at hotmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34362