size_t.sizeof == 2 && __LINE__.sizeof == 4

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 10 06:22:01 PDT 2017


On 7/10/17 8:41 AM, Luís Marques wrote:

> 1) Change `size_t line` to `int line`. The line is already 32 bits under 
> the covers (and I don't see the need to change that). The only issue 
> might be code breakage.

Not might, will. All exception derivatives call super(msg, file, line), 
which won't work if your exception defines its ctor with size_t line = 
__LINE__.

> 2) Make __LINE__ 16-bit for 16-bit targets. I don't think this option 
> makes much sense.

Agree.

> 3) Create a line_t type (in object.d?). Make it 32-bit for 16- and 
> 32-bit targets, and 64-bit for 64-bit targets. That's for avoiding 
> breakage, not because >4 B lines is actually needed, IMO.

Only sensible option at this point. And I agree it should be done.

-Steve


More information about the Digitalmars-d mailing list