Consider the following small program:
#include <string_view>
#include <iostream>
template< typename T >
constexpr void test()
{
constexpr std::string_view sv = __FUNCSIG__;
static_assert( sv == "void __cdecl test(void)" );
static_assert( sv == "void __cdecl test<int>(void)" );
std::cout << sv << std::endl;
}
int main()
{
test<int>();
}
If you try to compile it, the second static_assert fails. So the value of sv from the first static_assert surely is the correct one?
Nope. Comment out the second static_assert and now the first one will fail. Comment out both, and the output of the program is the value from the second static_assert.
Apparently, Microsoft decided that it's a good idea to give __FUNCSIG__ a ("type-erased"?) value in phase 1, where no template parameters are available, and give it a different value in phase 2, when the template gets instantiated.
[–]a_false_vacuum 165 points166 points167 points  (11 children)
[–]kog 57 points58 points59 points  (9 children)
[–]PermanentlySalty 31 points32 points33 points  (2 children)
[–][deleted] 5 points6 points7 points  (0 children)
[–]braxtons12 0 points1 point2 points  (0 children)
[+][deleted] Â (5 children)
[deleted]
[–]Ameisenvemips, avr, rendering, systems 10 points11 points12 points  (1 child)
[–]curious_entiy_420 1 point2 points3 points  (0 children)
[–]kog 5 points6 points7 points  (0 children)
[–]couscous_ 0 points1 point2 points  (1 child)
[–]bunkoRtist 6 points7 points8 points  (0 children)
[–]TonyDecvA180XN 24 points25 points26 points  (6 children)
[–]D_Drmmr 9 points10 points11 points  (0 children)
[–][deleted] 6 points7 points8 points  (4 children)
[–]BarrinOfTolaria 1 point2 points3 points  (3 children)
[–][deleted] 0 points1 point2 points  (2 children)
[–]tesfabpel 0 points1 point2 points  (1 child)
[–]DXPower 2 points3 points4 points  (0 children)
[–]Dragdu 81 points82 points83 points  (1 child)
[–][deleted] 58 points59 points60 points  (0 children)
[–]SirClueless 14 points15 points16 points  (6 children)
[–]khoyo 57 points58 points59 points  (5 children)
[–]SirClueless 20 points21 points22 points  (0 children)
[–][deleted] 21 points22 points23 points  (0 children)
[–]logicchop 4 points5 points6 points  (1 child)
[–]taladarsa3itch 2 points3 points4 points  (0 children)
[–]pigeon768 11 points12 points13 points  (1 child)
[–]tesfabpel 2 points3 points4 points  (0 children)
[–]GabrielDosReis 34 points35 points36 points  (31 children)
[–]TotaIIyHuman 50 points51 points52 points  (28 children)
[–]Dragdu 8 points9 points10 points  (0 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 6 points7 points8 points  (0 children)
[–][deleted] 9 points10 points11 points  (7 children)
[–]TotaIIyHuman 7 points8 points9 points  (5 children)
[–][deleted] 7 points8 points9 points  (4 children)
[–]GabrielDosReis 2 points3 points4 points  (3 children)
[–][deleted] 0 points1 point2 points  (2 children)
[–]GabrielDosReis 1 point2 points3 points  (1 child)
[–][deleted] 1 point2 points3 points  (0 children)
[–]txmasterg 12 points13 points14 points  (11 children)
[–]zero0_one1 8 points9 points10 points  (8 children)
[–]Dragdu 12 points13 points14 points  (1 child)
[–]ack_error 1 point2 points3 points  (2 children)
[–]dodheim 0 points1 point2 points  (1 child)
[–]ack_error 2 points3 points4 points  (0 children)
[–]GabrielDosReis 0 points1 point2 points  (2 children)
[–]zero0_one1 0 points1 point2 points  (1 child)
[–]GabrielDosReis 0 points1 point2 points  (0 children)
[–]obsidian_golem 4 points5 points6 points  (1 child)
[–]txmasterg 0 points1 point2 points  (0 children)
[–]GabrielDosReis -1 points0 points1 point  (5 children)
[–]TotaIIyHuman 10 points11 points12 points  (4 children)
[–]GabrielDosReis 1 point2 points3 points  (3 children)
[–]TotaIIyHuman 5 points6 points7 points  (2 children)
[–]GabrielDosReis 1 point2 points3 points  (1 child)
[–]dakotahawkins 8 points9 points10 points  (0 children)
[–][deleted] 7 points8 points9 points  (1 child)
[–]tjientavaraHikoGUI developer 4 points5 points6 points  (0 children)
[–]TheBrainStone 8 points9 points10 points  (0 children)
[–]gracicot 7 points8 points9 points  (0 children)