Click here to Skip to main content
15,562,816 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
AnswerRe: Navel gazing on coding style? Pin
SeattleC++19-Sep-22 7:03
SeattleC++19-Sep-22 7:03 
AnswerRe: Navel gazing on coding style? Pin
Juan Pablo Reyes Altamirano19-Sep-22 7:39
Juan Pablo Reyes Altamirano19-Sep-22 7:39 
AnswerRe: Navel gazing on coding style? Pin
Micha Berger19-Sep-22 8:14
Micha Berger19-Sep-22 8:14 
RantI thought I knew C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch17-Sep-22 15:57
mvahoney the codewitch17-Sep-22 15:57 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
PIEBALDconsult17-Sep-22 16:23
professionalPIEBALDconsult17-Sep-22 16:23 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch17-Sep-22 16:25
mvahoney the codewitch17-Sep-22 16:25 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
Randor 17-Sep-22 17:47
professional Randor 17-Sep-22 17:47 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch17-Sep-22 17:57
mvahoney the codewitch17-Sep-22 17:57 
Yeah, that's not really the issue I'm having though. I guess I wasn't clear. Let me see if I can explain it better.

See, if I put a constant in as per the second example of calling printf, it simply does mov esi, 65

C++
int main(int argc, char** argv) {
    constexpr const char a = 'A';
    // mov eax,65
    // movsx eax, al
    // mov esi, eax
    printf("%c\n",foo<-1>::test());
    // mov esi, 65
    printf("%c\n",a);
    return 0;
}


That's what I'd think it should do in the first example as well, printf or no.

It's using eax in the intermediary for reasons I can't fathom, and only when I call a forced inline function that should resolve to a compile time constant - and indeed *it does!* but it still generates extra instructions around it (fiddling with eax and al)

To bottom line it, why is the first example generating more code than the second example?
To err is human. Fortune favors the monsters.

GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
Randor 17-Sep-22 18:06
professional Randor 17-Sep-22 18:06 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch17-Sep-22 18:20
mvahoney the codewitch17-Sep-22 18:20 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
Randor 17-Sep-22 18:30
professional Randor 17-Sep-22 18:30 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch17-Sep-22 23:20
mvahoney the codewitch17-Sep-22 23:20 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
k505418-Sep-22 6:04
mvek505418-Sep-22 6:04 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch18-Sep-22 6:10
mvahoney the codewitch18-Sep-22 6:10 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
k505418-Sep-22 6:51
mvek505418-Sep-22 6:51 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch18-Sep-22 7:01
mvahoney the codewitch18-Sep-22 7:01 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
CPallini18-Sep-22 21:48
mveCPallini18-Sep-22 21:48 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch17-Sep-22 23:23
mvahoney the codewitch17-Sep-22 23:23 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
Randor 18-Sep-22 2:23
professional Randor 18-Sep-22 2:23 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch18-Sep-22 2:28
mvahoney the codewitch18-Sep-22 2:28 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
Randor 18-Sep-22 2:56
professional Randor 18-Sep-22 2:56 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch18-Sep-22 6:16
mvahoney the codewitch18-Sep-22 6:16 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
Randor 18-Sep-22 7:02
professional Randor 18-Sep-22 7:02 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch18-Sep-22 7:03
mvahoney the codewitch18-Sep-22 7:03 
GeneralRe: I thought I new C++ *sob* It has been inserting extra code on me this whole time. Pin
honey the codewitch18-Sep-22 7:20
mvahoney the codewitch18-Sep-22 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.