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

Aliased enums behaving oddly #36

Closed
SoylentGraham opened this issue May 4, 2020 · 10 comments
Closed

Aliased enums behaving oddly #36

SoylentGraham opened this issue May 4, 2020 · 10 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@SoylentGraham
Copy link

From the limitations, I see that aliases don't work, this would be fine, but I seem to be getting an odd case where the first-use of a value, is NOT the one used, furthermore, I'm getting 0x0 for a string, instead of the alias. (Either in my case would be fine, but not an empty string)

THEN, debugging in vs17, when I look at the strings table (which I guess is all the names baked into an array) my values START at 128 instead of 0
this is the enum https://github.com/SoylentGraham/SoyLib/blob/master/src/SoyPixels.h#L22
enum strings

I've been using this library for a while now without problems, even with this enum, so perhaps I've just missed this case, or in this particular code I'm using it in a strange way... (still investigating :)

@Neargye Neargye self-assigned this May 5, 2020
@Neargye Neargye added the invalid This doesn't seem right label May 5, 2020
@Neargye
Copy link
Owner

Neargye commented May 5, 2020

Hi @SoylentGraham, thanks for issues.
It looks very strange, could you please give your compilation flags?

@SoylentGraham
Copy link
Author

/JMC /permissive- /GS /W3 /Zc:wchar_t /ZI /Gm- /Od /sdl /Fd"D:\PopCap\PopCap.visualstudio\PopCap_x64_Debug\Temp\vc141.pdb" /Zc:inline /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /MTd /FC /Fa"D:\PopCap\PopCap.visualstudio\PopCap_x64_Debug\Temp\" /EHsc /nologo /Fo"D:\PopCap\PopCap.visualstudio\PopCap_x64_Debug\Temp\" /Fp"D:\PopCap\PopCap.visualstudio\PopCap_x64_Debug\Temp\PopCap.pch" /diagnostics:classic
Let me know if something like the verbose build output of visual studio will be more useful (Also that looks like I'm using a PCH, but definitely not!)

Back on osx today, so will see if I have the same problems, but pretty sure I don't (probably why I only just started seeing it go wrong)

I'll also find time to do a minimal repro

@SoylentGraham
Copy link
Author

Also note: I'm using the latest (I was a bit behind, but updating to master made no difference)

@SoylentGraham
Copy link
Author

Seems to be fine in xcode (CLANG_CXX_LANGUAGE_STANDARD = gnu++14)

@Neargye
Copy link
Owner

Neargye commented May 11, 2020

@SoylentGraham It looks like the behavior of aliases has broken on vs17, but is correct on vs19.

I’m still investigating this problem, but it seems necessary to add to the documentation that the order with aliases is undefined.

@SoylentGraham
Copy link
Author

Is the undefined order causing the empty strings? or is that a side effect? (In my case, I don't mind which comes up, but null strings are a problem)

@Neargye
Copy link
Owner

Neargye commented May 11, 2020

Unfortunately, yes, adding aliases occur empty strings, because the compiler cannot output either the actual value or the alias.

I can offer such a workaround

enum Type {
  Invalid = 0,
  Greyscale,
  ...
};

enum Aliases {
  Luma_Full = Greyscale,
  Nv12 = Yuv_8_88_Full,
  Nv21 = Yvu_8_88_Ntsc,
  I420 = Yuv_8_8_8_Full,
};

@Neargye Neargye closed this as completed May 31, 2020
@SoylentGraham
Copy link
Author

SoylentGraham commented May 31, 2020 via email

@Neargye
Copy link
Owner

Neargye commented May 31, 2020

@SoylentGraham In 2019, it works correctly. In 2017, unfortunately, with aliasing of enums, its has broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants