Opened 11 years ago

Closed 11 years ago

#290 closed defect (fixed)

Program termination does not flush output buffers

Reported by: Yuri Dario Owned by:
Priority: normal Milestone: libc-0.6.6
Component: gcc Version: 0.6.5
Severity: normal Keywords:
Cc:

Description

Output buffers are not flushed if file handle is not closed before program end. Sample testcase:

#include <stdio.h>
#include <string.h>

void main(void)
{
	char* buf = "this is my test buffer";

	FILE *fo = fopen( "test", "w");
	fwrite( buf, 1, strlen( buf), fo);
}

leaves a 0-byte file on disk. Adding flush or fclose restores proper behaviour.

Change History (4)

comment:1 by Yuri Dario, 11 years ago

This problem turned out building a c preprocessor (for AOO builds)

http://code.google.com/p/ucpp/

using gcc 4.7.3. But I just discovered an old build that was working, and built using the same sources and patches. The only difference if that old build was done with gcc 4.4.6.

comment:2 by Yuri Dario, 11 years ago

Resolution: invalid
Status: newclosed

The testcase built with gcc 4.4.6 works as designed.

This is not a libc bug, closing.

comment:3 by bird, 11 years ago

Component: libcgcc
Resolution: invalid
Status: closedreopened

comment:4 by bird, 11 years ago

Resolution: fixed
Status: reopenedclosed

It's a bug in the termination optimizations gccXYZ.dll employs, r3855 (branch) and r3856 (trunk) fixes this.

Note: See TracTickets for help on using tickets.