exoclime / HELIOS-K

Ultrafast opacity calculator for exoplanetary atmospheres.
https://helios-k2.readthedocs.io/
GNU General Public License v3.0
20 stars 6 forks source link

`hitran.cpp` does not run properly when compiled with clang++ #15

Closed Nicholaswogan closed 1 year ago

Nicholaswogan commented 1 year ago

Compiling hitran.cpp with clang++ instead of GNU g++ produces different results. The cause has to do with this line here: https://github.com/exoclime/HELIOS-K/blob/8e768db9d700e731af21bc22090a2f04e6dd9b94/hitran.cpp#L116

When I compile with GNU g++ with the warnings flag enabled, I get

(petit) nicholas@Nicholass-MacBook-Air-6 HELIOS-K % /opt/homebrew/bin/g++-12 hitran.cpp -o hitran -Wall
hitran.cpp: In function 'int main(int, char**)':
hitran.cpp:90:14: warning: unused variable 'c' [-Wunused-variable]
   90 |         char c[4];
      |              ^
hitran.cpp:96:14: warning: unused variable 'skip' [-Wunused-variable]
   96 |         char skip[4];
      |              ^~~~
hitran.cpp:116:32: warning: '%s' directive writing up to 3 bytes into a region of size 1 [-Wformat-overflow=]
  116 |                 sprintf(iiso, "%s", &iii[2]);
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
hitran.cpp:116:24: note: 'sprintf' output between 1 and 4 bytes into a destination of size 1
  116 |                 sprintf(iiso, "%s", &iii[2]);
sigrimm commented 1 year ago

Hi Nick, I fixed that line in the code, and the warning message is gone. Could you try again to compile and run it with glang++?

Nicholaswogan commented 1 year ago

The new hitran.cpp seems to work with clang++