andreasfertig / cppinsights

C++ Insights - See your source code with the eyes of a compiler
https://cppinsights.io
MIT License
4.09k stars 241 forks source link

explicit casting for const #610

Closed rghouzra closed 8 months ago

rghouzra commented 8 months ago
#include <iostream>
#include <limits.h>

int main (int argc, char *argv[]) {
  const int a = 10;
  int *p = (int *)&a;
  return 0;
}

give

#include <iostream>
#include <limits.h>

int main(int argc, char ** argv)
{
  const int a = 10;
  int * p = static_cast<int *>(&a);
  return 0;
}
andreasfertig commented 8 months ago

Hello @rghouzra,

thanks for spotting and reporting this issue! A fix is on its way.

Andreas

rghouzra commented 5 months ago

link for that example same goes for reference