Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22070

GCC will compile but clang wont

$
0
0

So in my finals there was an exercise asking what will the program print.

This is the code:

#include <stdio.h>

int main (){
    int x=5, y=4;

    if (x>y);
      printf("A");

    if(x=4)
      printf("%d",x+y);

     return 0;
}

When I try to compile it using gcc -ansi -pedantic -Werror on a Debian machine, it compiles just fine and outputs "A8".

However, when I try to compile it using clang -ansi -pedantic -Werror, I receive errors regarding the if (x=4) expression missing = and missing statement on if(x>y);.

Why does that happen, and which answer could be marked as correct?


Viewing all articles
Browse latest Browse all 22070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>