Doubts regarding the issue (bug 62181)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Respected Sir/Madam,
I have been working on an issue (bug 62181) [C/C++] Expected new warning:
"adding 'char' to a string does not append to the string"
[-Wstring-plus-int].This is asking for a warning being added to gcc for
such a case.Not using concat and indexing which were mentioned earlier as a
solution to the warning I tried the example given in  https://godbolt.org/
and was trying different permutations of addresses and pointers in clang
and gcc (trunk), I am not sure but I tried '-w' in compiler flags and it
worked fine for both clang and gcc ,it did not show any warning.I am not
sure what exactly did the flag do but the warning arises in other
optimizations.
I had a doubt regarding the output of a slightly modified code in which I
have taken a character instead of int ,
#include <stdio.h>
 char ch ='o';
char bar()  {
return 1;
 }
int foobar()  {
 return ch; }
 int main()
{   const char* a = "aa";
 const char *b = "bb" + bar();
const char *c = "cc" + foobar();
  printf("%s, %s, %s", a, b, c);
 return 0 ;
}
In the output I get zR when I did it with gcc and get unicode when done
with g++10.1 .I did not understand how does this output arise.Can you
please help me out with this?
Please correct me if I am going wrong somewhere.
Hoping for your reply soon.
Thanks and Regards,
Krishna Narayanan.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux