* pointer reference comparing with int in gcc 4.1.2
@ 2008-12-16 3:31 yangch
2008-12-16 3:48 ` me22
0 siblings, 1 reply; 4+ messages in thread
From: yangch @ 2008-12-16 3:31 UTC (permalink / raw)
To: gcc-help
This file cannot compile with gcc 4.1.2, but with gcc3.4.5 it works well.
#include <stdio.h>
#include <string.h>
typedef char str_t[10];
void f(str_t const &s)
{
printf("sizeof s:%d\n",sizeof(s));
if(s)
printf("%s\n",s);
}
int main()
{
str_t s1;
strcpy(s1,"abc");
f(s1);
printf("bytes of int:%d\n\n", sizeof(int));
return 0;
}
The command:
g++ test.cc
The output:
test.cc: In function 'void f(const char (&)[10])':
test.cc:9: error: invalid operands of types 'const char (&)[10]' and 'int'
to binary 'operator!='
I didn't find any hint in gcc change notes about this.Is there any way to
handle this without changing my source code?
--
View this message in context: http://www.nabble.com/pointer-reference-comparing-with-int-in-gcc-4.1.2-tp21026658p21026658.html
Sent from the gcc - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: pointer reference comparing with int in gcc 4.1.2
2008-12-16 3:31 pointer reference comparing with int in gcc 4.1.2 yangch
@ 2008-12-16 3:48 ` me22
2008-12-16 5:11 ` yangch
0 siblings, 1 reply; 4+ messages in thread
From: me22 @ 2008-12-16 3:48 UTC (permalink / raw)
To: yangch; +Cc: gcc-help
On Mon, Dec 15, 2008 at 22:30, yangch <yangchanghua@gmail.com> wrote:
>
> void f(str_t const &s)
> {
> printf("sizeof s:%d\n",sizeof(s));
> if(s)
> printf("%s\n",s);
> }
>
> test.cc: In function 'void f(const char (&)[10])':
> test.cc:9: error: invalid operands of types 'const char (&)[10]' and 'int'
> to binary 'operator!='
>
I think it's just a bug in 4.1.2. It compiles fine in 4.3.1.
HTH,
~ Scott
P.S. Rather odd that it talks about != there...
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-12-16 15:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 3:31 pointer reference comparing with int in gcc 4.1.2 yangch
2008-12-16 3:48 ` me22
2008-12-16 5:11 ` yangch
2008-12-16 15:09 ` me22
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).