Bug #1155 Bug in configure script
Submitted: 27 Aug 2003 15:59 Modified: 28 Aug 2003 3:06
Reporter: Torsten Schneider Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:3.23.57 OS:FreeBSD (FreeBSD)
Assigned to: CPU Architecture:Any

[27 Aug 2003 15:59] Torsten Schneider
Description:
I found a bug in the MySQL 3.23.57 configure script which made it
impossible to compile MySQL on some operating systems, e.g. FreeBSD 4.x.

There is a tiny test programme starting at line 16935 in configure:

#include "confdefs.h"
#include <stdio.h>
typedef long long longlong;
main()           
{
  longlong ll=1;
  float f;
  FILE *file=fopen("conftestval", "w");
  f = (float) ll;
  fprintf(file,"%g\n",f);
  close(file);
  exit (0);
}

This works on a few compilers I tested, but produced a segmentation
fault on most of my systems.

The problem is:
  FILE *file=fopen("conftestval", "w");
  /* ... */
  close(file);

When running configure it prints the misleading error message that the conversion between long long an float cannot be done.

How to repeat:
Just run configure on FreeBSD 4.x or 5.1-RELEASE

configure: error: Your compiler cannot convert a longlong value to a float!
If you are using gcc 2.8.# you should upgrade to egcs 1.0.3 or newer and try
again

Suggested fix:
Files opened with fopen() should be closed with fclose() and not with
close(). close() expects an integer and not a FILE *.

The correct code looks like this:

#include "confdefs.h"
#include <stdio.h>
typedef long long longlong;
main()           
{
  longlong ll=1;
  float f;
  FILE *file=fopen("conftestval", "w");
  f = (float) ll;
  fprintf(file,"%g\n",f);
  fclose(file);
  exit (0);
}
[28 Aug 2003 3:06] Sergei Golubchik
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the original bug instead.

Thank you for your interest in MySQL.