thepowersgang / mrustc

Alternative rust compiler (re-implementation)
MIT License
2.18k stars 109 forks source link

Function returning enum doesn't populate the return value #313

Closed SperkLabs closed 1 year ago

SperkLabs commented 1 year ago

I'm starting to try to learn Rust a bit by playing around in godbolt.org compiler explorer. I don't know what version of mrustc is in there, it just says "master". (I'm trying to build it on my work Windows laptop... I may just give up and build it on a linux PC I can SSH into)

I made a simple function that uses an enum as a return value to indicate if the result is valid or not. The generated C code returns a struct, but doesn't assign anything to the members of that struct.

https://godbolt.org/z/T1ssdafnz

thepowersgang commented 1 year ago

Very strange, I just tried using the same version (b6754f574f8846eb842feba4ccbeeecb10bdfacc according to --version) locally and it did populate rv

SperkLabs commented 1 year ago

I reported this to compiler explorer, and they disabled output filters, and then the generated code made sense. Thanks for the quick response, and sorry to waste your time on reproducing it. ;)