Favorite bug?

Derek Parnell derek at nomail.afraid.org
Mon Jul 2 01:01:28 PDT 2007


On Sun, 1 Jul 2007 23:42:37 -0700 (PDT), Brad Roberts wrote:

> I'll probably regret starting this thread in a day or to, but out of 
> curiosity's sake, if you had to pick a single bug to be fixed in the next 
> 1.x bug fix release, what would it be and why?  Remember, just one per 
> person.
> 
> NOTE: This is just a poll, not any sort of guarantee that it'll be fixed 
> or even looked at.  I'm doing this purely out of my own personal 
> curiosity.

Allowing inappropriate implicit conversions of signed values to unsigned
variables. For example allowing a 'uint' to be initialized to a negative
number. Why? Because it hides bugs that the compiler could catch.


C:\temp>type test.d
import std.stdio;
void foo(uint b)
{
    writefln(`foo says "%s"`, b);
}

void main()
{
  uint x = -1; // Should be a compile-time error
  writefln("%d", x);
  int y = -2;
  x = y; // Should be a runtime error at least.
  writefln("%d", x);

  foo(-3); // Should have a "no matching method" error
  foo(y); // Should have a "no matching method" error
}

C:\temp>dmd test
y:\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;

C:\temp>test
4294967295
4294967294
foo says "4294967293"
foo says "4294967294"


-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
2/07/2007 5:52:05 PM



More information about the Digitalmars-d mailing list