Opened 10 years ago

Closed 10 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 Changed 10 years ago by Yuri Dario

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 Changed 10 years ago by Yuri Dario

Resolution: invalid
Status: newclosed

The testcase built with gcc 4.4.6 works as designed.

This is not a libc bug, closing.

comment:3 Changed 10 years ago by bird

Component: libcgcc
Resolution: invalid
Status: closedreopened

comment:4 Changed 10 years ago by bird

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.