The exact version of GCC: 3.4.2
The system type; WINDOWS XP, DEV C++ IDE
The options given when GCC was configured/built; --
The complete command line that triggers the bug; NA
The compiler output (error messages, warnings, etc.); NONE
The preprocessed file (*.i*) that triggers the bug, generated by adding
-save-temps to the complete compilation command, or, in the case of a
bug report for the GNAT front end, a complete set of source files (see
below). ATTACHED
Code: ATTACHED
Problem: Input values and output values different! Tried the same on a
Fedora Core 5/GCC 4.1 System. Similar Error
# 1 "untest1.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "untest1.c"
# 1 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h"
1 3
# 19 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h"
3
# 1 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/_mingw.h"
1 3
# 20 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h"
2 3
# 1 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stddef.h"
1 3
# 1 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h" 1 3 4
# 213 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h" 3 4
typedef unsigned int size_t;
# 325 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h" 3 4
typedef short unsigned int wchar_t;
# 354 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h" 3 4
typedef short unsigned int wint_t;
# 7 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stddef.h"
2 3
# 27 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h"
2 3
# 1 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdarg.h"
1 3
# 1 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stdarg.h" 1 3 4
# 44 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 7 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdarg.h"
2 3
# 29 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h"
2 3
# 138
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
typedef struct _iobuf
{
char* _ptr;
int _cnt;
char* _base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char* _tmpfname;
} FILE;
# 163
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
extern __attribute__ ((dllimport)) FILE _iob[];
# 178
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
FILE* __attribute__((__cdecl__)) fopen (const char*, const char*);
FILE* __attribute__((__cdecl__)) freopen (const char*, const char*, FILE*);
int __attribute__((__cdecl__)) fflush (FILE*);
int __attribute__((__cdecl__)) fclose (FILE*);
int __attribute__((__cdecl__)) remove (const char*);
int __attribute__((__cdecl__)) rename (const char*, const char*);
FILE* __attribute__((__cdecl__)) tmpfile (void);
char* __attribute__((__cdecl__)) tmpnam (char*);
char* __attribute__((__cdecl__)) _tempnam (const char*, const char*);
int __attribute__((__cdecl__)) _rmtmp(void);
char* __attribute__((__cdecl__)) tempnam (const char*, const char*);
int __attribute__((__cdecl__)) rmtmp(void);
int __attribute__((__cdecl__)) setvbuf (FILE*, char*, int, size_t);
void __attribute__((__cdecl__)) setbuf (FILE*, char*);
int __attribute__((__cdecl__)) fprintf (FILE*, const char*, ...);
int __attribute__((__cdecl__)) printf (const char*, ...);
int __attribute__((__cdecl__)) sprintf (char*, const char*, ...);
int __attribute__((__cdecl__)) _snprintf (char*, size_t, const char*, ...);
int __attribute__((__cdecl__)) vfprintf (FILE*, const char*, __gnuc_va_list);
int __attribute__((__cdecl__)) vprintf (const char*, __gnuc_va_list);
int __attribute__((__cdecl__)) vsprintf (char*, const char*, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsnprintf (char*, size_t, const char*,
__gnuc_va_list);
int __attribute__((__cdecl__)) snprintf(char* s, size_t n, const char* format,
...);
extern __inline__ int __attribute__((__cdecl__))
vsnprintf (char* s, size_t n, const char* format, __gnuc_va_list arg)
{ return _vsnprintf ( s, n, format, arg); }
int __attribute__((__cdecl__)) vscanf (const char * __restrict__,
__gnuc_va_list);
int __attribute__((__cdecl__)) vfscanf (FILE * __restrict__, const char *
__restrict__,
__gnuc_va_list);
int __attribute__((__cdecl__)) vsscanf (const char * __restrict__,
const char * __restrict__, __gnuc_va_list);
int __attribute__((__cdecl__)) fscanf (FILE*, const char*, ...);
int __attribute__((__cdecl__)) scanf (const char*, ...);
int __attribute__((__cdecl__)) sscanf (const char*, const char*, ...);
int __attribute__((__cdecl__)) fgetc (FILE*);
char* __attribute__((__cdecl__)) fgets (char*, int, FILE*);
int __attribute__((__cdecl__)) fputc (int, FILE*);
int __attribute__((__cdecl__)) fputs (const char*, FILE*);
char* __attribute__((__cdecl__)) gets (char*);
int __attribute__((__cdecl__)) puts (const char*);
int __attribute__((__cdecl__)) ungetc (int, FILE*);
int __attribute__((__cdecl__)) _filbuf (FILE*);
int __attribute__((__cdecl__)) _flsbuf (int, FILE*);
extern __inline__ int __attribute__((__cdecl__)) getc (FILE* __F)
{
return (--__F->_cnt >= 0)
? (int) (unsigned char) *__F->_ptr++
: _filbuf (__F);
}
extern __inline__ int __attribute__((__cdecl__)) putc (int __c, FILE* __F)
{
return (--__F->_cnt >= 0)
? (int) (unsigned char) (*__F->_ptr++ = (char)__c)
: _flsbuf (__c, __F);
}
extern __inline__ int __attribute__((__cdecl__)) getchar (void)
{
return (--(&_iob[0])->_cnt >= 0)
? (int) (unsigned char) *(&_iob[0])->_ptr++
: _filbuf ((&_iob[0]));
}
extern __inline__ int __attribute__((__cdecl__)) putchar(int __c)
{
return (--(&_iob[1])->_cnt >= 0)
? (int) (unsigned char) (*(&_iob[1])->_ptr++ = (char)__c)
: _flsbuf (__c, (&_iob[1]));}
# 297
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
size_t __attribute__((__cdecl__)) fread (void*, size_t, size_t, FILE*);
size_t __attribute__((__cdecl__)) fwrite (const void*, size_t, size_t, FILE*);
int __attribute__((__cdecl__)) fseek (FILE*, long, int);
long __attribute__((__cdecl__)) ftell (FILE*);
void __attribute__((__cdecl__)) rewind (FILE*);
# 330
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
typedef long long fpos_t;
int __attribute__((__cdecl__)) fgetpos (FILE*, fpos_t*);
int __attribute__((__cdecl__)) fsetpos (FILE*, const fpos_t*);
int __attribute__((__cdecl__)) feof (FILE*);
int __attribute__((__cdecl__)) ferror (FILE*);
# 355
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
void __attribute__((__cdecl__)) clearerr (FILE*);
void __attribute__((__cdecl__)) perror (const char*);
FILE* __attribute__((__cdecl__)) _popen (const char*, const char*);
int __attribute__((__cdecl__)) _pclose (FILE*);
FILE* __attribute__((__cdecl__)) popen (const char*, const char*);
int __attribute__((__cdecl__)) pclose (FILE*);
int __attribute__((__cdecl__)) _flushall (void);
int __attribute__((__cdecl__)) _fgetchar (void);
int __attribute__((__cdecl__)) _fputchar (int);
FILE* __attribute__((__cdecl__)) _fdopen (int, const char*);
int __attribute__((__cdecl__)) _fileno (FILE*);
int __attribute__((__cdecl__)) _fcloseall(void);
FILE* __attribute__((__cdecl__)) _fsopen(const char*, const char*, int);
int __attribute__((__cdecl__)) _getmaxstdio(void);
int __attribute__((__cdecl__)) _setmaxstdio(int);
int __attribute__((__cdecl__)) fgetchar (void);
int __attribute__((__cdecl__)) fputchar (int);
FILE* __attribute__((__cdecl__)) fdopen (int, const char*);
int __attribute__((__cdecl__)) fileno (FILE*);
# 399
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
# 1
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/sys/types.h"
1 3
# 21
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/sys/types.h" 3
# 1 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stddef.h"
1 3
# 1 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h" 1 3 4
# 151 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 7 "C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stddef.h"
2 3
# 22
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/sys/types.h"
2 3
typedef long time_t;
typedef long long __time64_t;
typedef long _off_t;
typedef _off_t off_t;
typedef unsigned int _dev_t;
typedef _dev_t dev_t;
typedef short _ino_t;
typedef _ino_t ino_t;
typedef int _pid_t;
typedef _pid_t pid_t;
typedef unsigned short _mode_t;
typedef _mode_t mode_t;
typedef int _sigset_t;
typedef _sigset_t sigset_t;
typedef long _ssize_t;
typedef _ssize_t ssize_t;
typedef long long fpos64_t;
typedef long long off64_t;
# 400
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 2 3
extern __inline__ FILE* __attribute__((__cdecl__)) fopen64 (const char*
filename, const char* mode)
{
return fopen (filename, mode);
}
int __attribute__((__cdecl__)) fseeko64 (FILE*, off64_t, int);
extern __inline__ off64_t __attribute__((__cdecl__)) ftello64 (FILE * stream)
{
fpos_t pos;
if (fgetpos(stream, &pos))
return -1LL;
else
return ((off64_t) pos);
}
# 428
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
int __attribute__((__cdecl__)) fwprintf (FILE*, const wchar_t*, ...);
int __attribute__((__cdecl__)) wprintf (const wchar_t*, ...);
int __attribute__((__cdecl__)) swprintf (wchar_t*, const wchar_t*, ...);
int __attribute__((__cdecl__)) _snwprintf (wchar_t*, size_t, const wchar_t*,
...);
int __attribute__((__cdecl__)) vfwprintf (FILE*, const wchar_t*,
__gnuc_va_list);
int __attribute__((__cdecl__)) vwprintf (const wchar_t*, __gnuc_va_list);
int __attribute__((__cdecl__)) vswprintf (wchar_t*, const wchar_t*,
__gnuc_va_list);
int __attribute__((__cdecl__)) _vsnwprintf (wchar_t*, size_t, const wchar_t*,
__gnuc_va_list);
int __attribute__((__cdecl__)) fwscanf (FILE*, const wchar_t*, ...);
int __attribute__((__cdecl__)) wscanf (const wchar_t*, ...);
int __attribute__((__cdecl__)) swscanf (const wchar_t*, const wchar_t*, ...);
wint_t __attribute__((__cdecl__)) fgetwc (FILE*);
wint_t __attribute__((__cdecl__)) fputwc (wchar_t, FILE*);
wint_t __attribute__((__cdecl__)) ungetwc (wchar_t, FILE*);
wchar_t* __attribute__((__cdecl__)) fgetws (wchar_t*, int, FILE*);
int __attribute__((__cdecl__)) fputws (const wchar_t*, FILE*);
wint_t __attribute__((__cdecl__)) getwc (FILE*);
wint_t __attribute__((__cdecl__)) getwchar (void);
wchar_t* __attribute__((__cdecl__)) _getws (wchar_t*);
wint_t __attribute__((__cdecl__)) putwc (wint_t, FILE*);
int __attribute__((__cdecl__)) _putws (const wchar_t*);
wint_t __attribute__((__cdecl__)) putwchar (wint_t);
FILE* __attribute__((__cdecl__)) _wfdopen(int, wchar_t *);
FILE* __attribute__((__cdecl__)) _wfopen (const wchar_t*, const wchar_t*);
FILE* __attribute__((__cdecl__)) _wfreopen (const wchar_t*, const wchar_t*,
FILE*);
FILE* __attribute__((__cdecl__)) _wfsopen (const wchar_t*, const wchar_t*,
int);
wchar_t* __attribute__((__cdecl__)) _wtmpnam (wchar_t*);
wchar_t* __attribute__((__cdecl__)) _wtempnam (const wchar_t*, const wchar_t*);
int __attribute__((__cdecl__)) _wrename (const wchar_t*, const wchar_t*);
int __attribute__((__cdecl__)) _wremove (const wchar_t*);
void __attribute__((__cdecl__)) _wperror (const wchar_t*);
FILE* __attribute__((__cdecl__)) _wpopen (const wchar_t*, const wchar_t*);
int __attribute__((__cdecl__)) snwprintf (wchar_t* s, size_t n, const wchar_t*
format, ...);
extern __inline__ int __attribute__((__cdecl__))
vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __gnuc_va_list arg)
{ return _vsnwprintf ( s, n, format, arg);}
int __attribute__((__cdecl__)) vwscanf (const wchar_t * __restrict__,
__gnuc_va_list);
int __attribute__((__cdecl__)) vfwscanf (FILE * __restrict__,
const wchar_t * __restrict__, __gnuc_va_list);
int __attribute__((__cdecl__)) vswscanf (const wchar_t * __restrict__,
const wchar_t * __restrict__, __gnuc_va_list);
# 482
"C:/apps/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../../include/stdio.h" 3
FILE* __attribute__((__cdecl__)) wpopen (const wchar_t*, const wchar_t*);
wint_t __attribute__((__cdecl__)) _fgetwchar (void);
wint_t __attribute__((__cdecl__)) _fputwchar (wint_t);
int __attribute__((__cdecl__)) _getw (FILE*);
int __attribute__((__cdecl__)) _putw (int, FILE*);
wint_t __attribute__((__cdecl__)) fgetwchar (void);
wint_t __attribute__((__cdecl__)) fputwchar (wint_t);
int __attribute__((__cdecl__)) getw (FILE*);
int __attribute__((__cdecl__)) putw (int, FILE*);
# 2 "untest1.c" 2
typedef union
{
struct
{
int a;
char b;
double c;
char d;
} stru;
char b[14];
} Untest;
main()
{
FILE *f1;
int i;
Untest t1, t2;
f1 = fopen("meowmeow.bin", "w");
t1.stru.a = 4;
t1.stru.b = 'a';
t1.stru.c = 34.555;
t1.stru.d = 'H';
for (i=0; i<14; i++)
fputc(t1.b[i], f1);
fclose(f1);
f1 = fopen("meowmeow.bin", "r+b");
for (i=0; i<14; i++)
t2.b[i] = fgetc(f1);
printf("a = %d\n", t2.stru.a);
printf("b = %c\n", t2.stru.b);
printf("c = %f\n", t2.stru.c);
printf("d = %c\n", t2.stru.d);
fclose(f1);
getch();
}
#include <stdio.h>
typedef union
{
struct
{
int a;
char b;
double c;
char d;
} stru;
char b[14];
} Untest;
main()
{
FILE *f1;
int i;
Untest t1, t2;
f1 = fopen("meowmeow.bin", "w");
t1.stru.a = 4;
t1.stru.b = 'a';
t1.stru.c = 34.555;
t1.stru.d = 'H';
printf("a = %d\n", t1.stru.a);
printf("b = %c\n", t1.stru.b);
printf("c = %f\n", t1.stru.c);
printf("d = %c\n", t1.stru.d);
for (i=0; i<14; i++)
fputc(t1.b[i], f1);
fclose(f1);
f1 = fopen("meowmeow.bin", "r+b");
for (i=0; i<14; i++)
t2.b[i] = fgetc(f1);
printf("a = %d\n", t2.stru.a);
printf("b = %c\n", t2.stru.b);
printf("c = %f\n", t2.stru.c);
printf("d = %c\n", t2.stru.d);
fclose(f1);
getch();
}