public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Doubts regarding the issue (bug 62181)
@ 2022-02-03 18:45 Krishna Narayanan
  2022-02-03 20:47 ` Jonathan Wakely
  2022-02-03 20:49 ` Jonathan Wakely
  0 siblings, 2 replies; 6+ messages in thread
From: Krishna Narayanan @ 2022-02-03 18:45 UTC (permalink / raw)
  To: gcc-help

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-02-04 16:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03 18:45 Doubts regarding the issue (bug 62181) Krishna Narayanan
2022-02-03 20:47 ` Jonathan Wakely
2022-02-04 11:35   ` Krishna Narayanan
2022-02-04 12:13     ` Jonathan Wakely
2022-02-04 16:24       ` Krishna Narayanan
2022-02-03 20:49 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).