Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
Problems of 64-bit code in real program…

Problems of 64-bit code in real programs: FreeBSD

Feb 02 2009

While telling people about problems and difficulties of developing 64-bit applications I often hear in response: "You just should write programs well and there will be no problems". What only have we done trying to persuade people that this view is absurd! We wrote articles, gave examples but there still were those who would stick to their opinion.

Surfing recently through the net searching for discussions of problems relating to 64-bit, at some forum I came across a description of strange behavior of a program for reading files. This program couldn't read a file of more than 2 GB although the code was correct:

size_t size;
size = fread(...);

Investigation showed that the error was... inside fread function of FreeBSD!

It is difficult to believe in this that's why I will prove my words. You can see the code of fread function in the repository of FreeBSD source code http://svnweb.freebsd.org/:

size_t
fread(void * __restrict buf, size_t size,
        size_t count, FILE * __restrict fp)
{
  int ret;
  FLOCKFILE(fp);
  ret = __fread(buf, size, count, fp);
  FUNLOCKFILE(fp);
  return (ret);
}

Oh my God, how could one define ret variable as int? Of course it's absolutely incorrect. This error was corrected... only in December 2008:

size_t
fread(void * __restrict buf, size_t size,
        size_t count, FILE * __restrict fp)
{
  size_t ret;
  FLOCKFILE(fp);
  ret = __fread(buf, size, count, fp);
  FUNLOCKFILE(fp);
  return (ret);
}

It is astonishing that an error in FreeBSD was corrected only in the end of 2008. Perhaps 64-bit systems are not called-for yet?

Popular related articles


Comments (0)

Next comments next comments
close comment form