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

Using reinterpret_cast in constexpr expression #19

Open
lamer0k opened this issue Jul 11, 2019 · 1 comment
Open

Using reinterpret_cast in constexpr expression #19

lamer0k opened this issue Jul 11, 2019 · 1 comment

Comments

@lamer0k
Copy link

lamer0k commented Jul 11, 2019

Hello Christian , greate work.!
I have a question about the contexpr.
In the file iomm.hpp, line 53, the next code:

using PtrType = volatile T*;
static constexpr PtrType ptr = reinterpret_cast<PtrType>(_addr);

C++ reject to use reinterpret_cast in constexpr expression. Does it realy work on gcc compiler?
It coul be a cause that all objects will be placed in RAM, and all functions also will not be run on compile time.

@cmnrd
Copy link
Owner

cmnrd commented Jul 12, 2019

Thanks for the feedback lamer0k! Since I don't use AVRs this often anymore, I didn't work on this project for some years now. Back then this code used to work. I didn't find a clear statement, but it might be that this only became illegal in C++14 and was not illegal in C++11 (only unspecified). Back then I was new to C++11 and not aware that this is unspecified behaviour.

I found this https://arne-mertz.de/2017/06/stepping-away-from-define/ in a quick search. To me, this looks like a good alternative for handling the pointers in yalla.

I currently don't have the time to fix this myself, but I would be happy to accept a pull request.

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