Самая приметивная программа вылетает при работе с указателями.
Вот код программы
//File tmp.c
#include <stdio.h>
int main()
{
int *ptmp;
*ptmp=12; //Вот здесь все и происходит
}
**********************Сообщение в окне Message Window***********************
Compiling: tmp.c
no errors
Creating: tmp.exe
no errors
Call frame traceback:
tmp.c(8) in function main
in function __crt1_startup+178
**********************Сообщение в окне Output from GDB*******************************
GNU gdb 5.0
Copyright 2000 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-pc-msdosdjgpp".
Breakpoint 1 at 0x1576: file tmp.c, line 8.
main () at tmp.c:8
8 *ptmp=10;
Program received signal SIGSEGV, Segmentation fault.
0x1579 in main () at tmp.c:8
8 *ptmp=10;
Program exited with code 0377.
**********************Сообщение в окне contents of stderr from tmp.exe **************
Exiting due to signal SIGSEGV
General Protection Fault at eip=00001579, error=0006
eax=00164f65 ebx=0000836d ecx=00000000 edx=0000033f esi=00000054 edi=0000cd48
ebp=002c8fe0 esp=002c8fc8 program=D:\Programs\djgpp\bin\tmp.exe
cs: sel=0217 base=836d6000 limit=fff06fff
ds: sel=021f base=836d6000 limit=fff06fff
es: sel=021f base=836d6000 limit=fff06fff
fs: sel=01ef base=00013090 limit=00003fff
gs: sel=022f base=00000000 limit=0010ffff
ss: sel=021f base=836d6000 limit=fff06fff
App stack: [002c9000..00249000] Exceptn stack: [0000cca8..0000ad68]
Call frame traceback EIPs:
0x00001579
0x00002922
Раньше все на ура работало.
... скорее, проблема в исходном тексте26.07.01 10:52 Автор: ukv Статус: Незарегистрированный пользователь
> int main() > { > int *ptmp; > > *ptmp=12; //Вот здесь все и происходит > } >
Любой указатель надо инициализировать перед использованием.
А неинициализированный указатель будет адресовать либо нулевую ячейку
(если это статическая переменная), либо вообще черт знает что (для автоматических переменных, как в данном случае). Компилятор здесь не при чем.