What is going on in this code?

Carlin via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 14 03:14:26 PDT 2016


I have encountered a weird error that only seems to occur when 
building in debug mode. In release everything works fine. I 
wanted to post here before raising a new issue in case I'm just 
horribly blind at what is happening here.

---
import std.stdio;
import std.bitmanip;

ubyte[] serialize(uint t)
{
	ubyte[] bytes = nativeToBigEndian(t);
	return bytes;
}

void main()
{
	writeln(serialize(0));
}
---

$ dub --build=debug
Performing "debug" build using dmd for x86.
test ~master: target for configuration "application" is up to 
date.
To force a rebuild of up-to-date targets, run again with --force.
Running .\test.exe
[12, 254, 24, 0]

$ dub --build=release
Performing "release" build using dmd for x86.
test ~master: target for configuration "application" is up to 
date.
To force a rebuild of up-to-date targets, run again with --force.
Running .\test.exe
[0, 0, 0, 0]

Why is it returning a different range in debug but not in release?


More information about the Digitalmars-d mailing list