Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

I found a bug/ error in C++ compiler/ language

Revision en2, by Mr.Adnan, 2019-01-11 21:07:57

I don't know if the error is from C++ compiler or language.

Try this two codes: I tried to compare two string "a" and "adnan", in two codes, it giving me two different outputs, where the second one is correct.

#include<bits/stdc++.h>
using namespace std;

int main()
{
  //  cout<<("a">"adnan")<<endl;
   cout<<("a"> "adnan" ? "a": "adnan")<<endl;

}
/* The output is: 
a

which is incorrect.
*/

and

#include<bits/stdc++.h>
using namespace std;

int main()
{
   cout<<("a">"adnan")<<endl;
   cout<<("a"> "adnan" ? "a": "adnan")<<endl;


}
/* the output is:
0
adnan
*/

which is correct.

I tried from different compilers I've tested it from codechef's compiler also: c++ 14, from ideone: C++, C++ 14

And found the same error. Hope it'll be seen by the C++ language

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English Mr.Adnan 2019-01-11 21:35:31 189
en4 English Mr.Adnan 2019-01-11 21:11:46 69
en3 English Mr.Adnan 2019-01-11 21:08:26 10 Tiny change: ' language \n\n' -> ' language Authority.\n\n'
en2 English Mr.Adnan 2019-01-11 21:07:57 186 Tiny change: 'I don't kn' -> '``I don't kn'
en1 English Mr.Adnan 2019-01-11 20:58:03 711 Initial revision (published)