Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hlc] Using unsigned shift right operator on Int64 results in code that does not compile on MSVC without manually including a particular header. #11718

Closed
RandomityGuy opened this issue Jul 12, 2024 · 0 comments · Fixed by #11721

Comments

@RandomityGuy
Copy link

Platform Description

OS: Windows 10
Haxe Version: 4.3.4
Using MSVC to compile.

Bug Description

Encountered this bug while trying to compile my game through HL/C, narrowed down the cause to be a missing header.
Basically if you perform the unsigned shift right operation on an Int64, it generates casts to uint64_t whose definition is in a header which is not automatically included during code generation. The resulting code does compile on Mac/Linux though so this is specifically a Windows MSVC problem.

Reproducible Example

package;

import haxe.Int64;

class Main {
	static function main() {
		var x = Int64.fromFloat(1000);
		var y:Int64 = x >>> 2;
		trace(y);
	}
}

Generated Code

void Main_main() {
	vdynobj *r11;
	String r8, r9;
	vvirtual *r12;
	int64 r0, r3, r5;
	haxe__$Log r7;
	vclosure *r6;
	double r1;
	vdynamic *r10;
	int r4;
	r1 = 1000.;
	r0 = haxe__Int64_Int64_Impl__fromFloat(r1);
	r4 = 2;
	r5 = (int)r4;
	r3 = ((uint64_t)r0) >> r5; // uint64_t is undefined here for MSVC
	r7 = (haxe__$Log)g$_haxe_Log;
	r6 = r7->trace;
	if( r6 == NULL ) hl_null_access();
	r8 = (String)s$;
	r10 = hl_alloc_dynamic(&t$_i64);
	r10->v.i64 = r3;
	r9 = Std_string(r10);
	r8 = String___add__(r8,r9);
	r11 = hl_alloc_dynobj();
	...

Conclusion

I guess I could just fork HL and add the necessary include/definition to hl.h, but still it would be better for it to just work without having to mess with the sources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant