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

failure in example code on page about enum representation. #848

Open
EricDelvalet opened this issue Feb 24, 2023 · 1 comment
Open

failure in example code on page about enum representation. #848

EricDelvalet opened this issue Feb 24, 2023 · 1 comment
Assignees

Comments

@EricDelvalet
Copy link

in the page: https://learn.adacore.com/courses/whats-new-in-ada-2022/chapters/enum_val.html#before-ada-2022
build and run of the last example will give the output:

Console Output:
$ gprbuild -q -P main.gpr
Build completed successfully.
$ ./main
To_Int(False) = 3
To_Int(True) = 6
From_Int (3) =TRUE -- [sic!] should have been FALSE
From_Int (6) =TRUE

My knowledge of Ada is too limited to understand why this is wrong, I see nothing obvious in the code example that will explain the error.
I tried it with my own "anonymous" enum type and it is working as expected, so the problem may have something to do with the line "type My_Boolean is new Boolean"
But anyway, it is rather bad when a given example code fails to show what it is supposed to illustrate.

Cordially

@reznikmm
Copy link
Contributor

That is sad, indeed. I've tried the demo with GNAT GPL 2020, GNAT GPL 2021, GCC 10, GCC 12, GCC 13 and it works as expected. But with GCC 12 it fails :( I guess, this is a compiler bug.

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

2 participants