-
-
Notifications
You must be signed in to change notification settings - Fork 264
Is the tranformed code in https://cppinsights.io identical with the one transformed by my local compiler clang-1200.0.32.29 #424
Copy link
Copy link
Closed
Description
In view of my lack of knowledge on features of different compiler versions.
I submit my source code (max1.cc as follows) on https://cppinsights.io/
#include <cstdio>
template<typename T1, typename T2>
auto max(T1 a, T2 b) {
return b < a ? a : b;
}
int main() {
int a = 1;
float b = 2.2;
auto x = max<int, float>(a, b);
}and the transformed Insignt shows:
#include <cstdio>
template<typename T1, typename T2>
auto max(T1 a, T2 b) {
return b < a ? a : b;
}
#ifdef INSIGHTS_USE_TEMPLATE
template<>
float max<int, float>(int a, float b)
{
return b < static_cast<float>(a) ? static_cast<float>(a) : b;
}
#endif
int main()
{
int a = 1;
float b = static_cast<float>(2.2000000000000002);
float x = max<int, float>(a, b);
}But I wonder whether this transformation is identical with the one that my local compiler does.
As mentioned in the compatibility part of README.md, the most recent stable version of clang is supported.
So, will the transformaton process influenced by the version of clang?
PS. My clang version on macos
$ /usr/bin/clang --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/binPSS. My CMakeLists.txt
cmake_minimum_required(VERSION 3.18)
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
set(CMAKE_CXX_STANDARD 14)
project(tmp)
add_executable(max1 src/max1.cc)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels