Opened 6 years ago

Closed 6 years ago

#290 closed defect (fixed)

Program termination does not flush output buffers

Reported by: ydario 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 6 years ago by ydario

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 6 years ago by ydario

  • Resolution set to invalid
  • Status changed from new to closed

The testcase built with gcc 4.4.6 works as designed.

This is not a libc bug, closing.

comment:3 Changed 6 years ago by bird

  • Component changed from libc to gcc
  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:4 Changed 6 years ago by bird

  • Resolution set to fixed
  • Status changed from reopened to closed

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.