PROPOSAL: Disallow integer values as variable names
A recent upgrade of the HDF5 library into ITK caused massive headaches because of this strange case. Several very seasoned developers have been working on tracking this bug down for several months. It was very difficult to find because of an allowed behavior in Cmake.
I have proposed an upstream fix to HDF5 (https://github.com/HDFGroup/hdf5/pull/1332) to remedy their buggy code.
cmake_minimum_required(VERSION 3.15.3 FATAL_ERROR) project(test_case) # A silly test case to demonstrate what # happened in the HDF5 failure set(0 7) set(1 7) if(0 EQUAL 1) message(STATUS "A very strange situation where 0 equals 1") endif() set(myvar 6) if(myvar GREATER 0) message(STATUS "We would expect this to be printed") else() message(STATUS "But instead this is what is printed") endif()
I propose that by default a warning be issued if an integer value is used as a variable name. Additionally, if a future policy (or flag of some kind) be set to prohibit use of integer values as variable names.
Note the code in ITK that failed was
list(length mylist numelements) if(numelements GREATER 0) endif()
Which rarely gave the wrong answer because mylist was usually '0' or >> '1'. It only gave the wrong results when numelements =1.
=============== Feel free to close and ingore this as you see fit.