You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read the documentation at readthedocs and the issue is not addressed there.
I have tested that the issue is present in current master branch (aka latest git).
I have searched the issue tracker for a similar issue.
If there is a stack dump, I have decoded it.
I have filled out all fields below.
Platform
Hardware: ESP-12
Core Version: current master
Development Env: Platformio
Operating System: MacOS
Problem Description
This isn't really reproducible, it's more of a theoterical problem. Technically if a variable value is declared as const the compiler can assume it will never change, so changing may trigger UB. Which means doing that in some platforms causes problems, currently to the CPU we target, with the compiler we target, there is no side-effect. And there is no statical analyzer to catch it, it's a silent UB.
Basic Infos
Platform
Problem Description
This isn't really reproducible, it's more of a theoterical problem. Technically if a variable value is declared as const the compiler can assume it will never change, so changing may trigger UB. Which means doing that in some platforms causes problems, currently to the CPU we target, with the compiler we target, there is no side-effect. And there is no statical analyzer to catch it, it's a silent UB.
Because of SSO the sketch below technically is UB. As described by https://en.cppreference.com/w/cpp/language/const_cast
There also are many real life examples of programs being broken by this, like: https://stackoverflow.com/questions/8954260/const-cast-doesnt-work-c
Of course the circunstances are different, but it's not ideal to live with UB just because it works for now.
String::substring
andString::lastIndexOf
both do this. Ideally wbuffer() shouldn't be const to avoid this problem happening by accident.MCVE Sketch
The text was updated successfully, but these errors were encountered: