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

enum behavior still wrong #97

Closed
fuhsnn opened this issue Nov 23, 2024 · 0 comments
Closed

enum behavior still wrong #97

fuhsnn opened this issue Nov 23, 2024 · 0 comments

Comments

@fuhsnn
Copy link
Owner

fuhsnn commented Nov 23, 2024

This should pass:

#include <stdint.h>
enum e0 {
    e0_i32max = 0x7FFFFFFF,
};
_Static_assert(_Generic(e0_i32max, int32_t:1), "");
_Static_assert(_Generic((enum e0)0, uint32_t:1), "");

enum e1 {
    e1_i32max = 0x7FFFFFFF,
    e1_i32max_plus1,
};
_Static_assert(_Generic(e1_i32max, uint32_t:1), "");
_Static_assert(_Generic((enum e1)0, uint32_t:1), "");

enum e2 {
    e2_neg = -1,
    e2_i32max = 0x7FFFFFFF,
    e2_i32max_plus1,
};
_Static_assert(_Generic(e2_i32max, int64_t:1), "");
_Static_assert(_Generic((enum e2)0, int64_t:1), "");

enum e3 {
    e3_i32max = 0x7FFFFFFF,
    e3_neg = -1
};
_Static_assert(_Generic(e3_i32max, int32_t:1), "");
_Static_assert(_Generic((enum e3)0, int32_t:1), "");

enum e4 {
    e4_u32max = 0xFFFFFFFF,
};
_Static_assert(_Generic(e4_u32max, uint32_t:1), "");
_Static_assert(_Generic((enum e4)0, uint32_t:1), "");

enum e5 {
    e5_u32max = 0xFFFFFFFF,
    e5_neg = -1
};
_Static_assert(_Generic(e5_u32max, int64_t:1), "");
_Static_assert(_Generic((enum e5)0, int64_t:1), "");

enum e6 {
    e6_u32max = 0xFFFFFFFF,
    e6_u32max_plus1,
};
_Static_assert(_Generic(e6_u32max_plus1, uint64_t:1), "");
_Static_assert(_Generic((enum e6)0, uint64_t:1), "");

enum e7 {
    e7_u32max = 0xFFFFFFFF,
    e7_u32max_plus1,
    e7_neg = -1
};
_Static_assert(_Generic(e7_u32max_plus1, int64_t:1), "");
_Static_assert(_Generic((enum e7)0, int64_t:1), "");

https://godbolt.org/z/8coPdvG4f

@fuhsnn fuhsnn closed this as completed in 9c18a36 Nov 28, 2024
fuhsnn added a commit that referenced this issue Nov 29, 2024
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

No branches or pull requests

1 participant