public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/6774: printf("%lld") prints bad values
@ 2002-05-22 17:46 brian
  0 siblings, 0 replies; 5+ messages in thread
From: brian @ 2002-05-22 17:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6774
>Category:       c++
>Synopsis:       printf("%lld") prints bad values
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 22 17:46:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Brian Ceccarelli
>Release:        g++ or g++3
>Organization:
>Environment:
Red Hat Linux on Intel
Mandrake Linux on Intel
>Description:
# include <stdio.h>

int main(int c, char *argv[])
{
   long long   i;
   long long   n;

   for (i=0LL; i<63LL; i++)
      {
      n = 1LL << i;
      printf("1 << %d = %lld\n", i, n);
      }

   return 0;

}


%lld is giving 64 bit results for i < 32 and 0 for i >= 32.
>How-To-Repeat:
Execute above program.
>Fix:
None that I can see.   Is 64-bit integer formatting supported by g++ compilers?  Doesn't seem so.
>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/6774: printf("%lld") prints bad values
@ 2002-05-23  9:26 Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2002-05-23  9:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/6774; it has been noted by GNATS.

From: Richard Henderson <rth@redhat.com>
To: Brian Ceccarelli <brian@talusmusic.com>
Cc: rth@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
   nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/6774: printf("%lld") prints bad values
Date: Thu, 23 May 2002 09:17:08 -0700

 On Thu, May 23, 2002 at 10:58:12AM -0400, Brian Ceccarelli wrote:
 >    Do you want me to file a separate bug report on this?
 
 No, since this almost certainly isn't going to be a compiler bug.
 
 
 r~


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

* RE: c++/6774: printf("%lld") prints bad values
@ 2002-05-23  7:56 Brian Ceccarelli
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Ceccarelli @ 2002-05-23  7:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/6774; it has been noted by GNATS.

From: "Brian Ceccarelli" <brian@talusmusic.com>
To: <rth@gcc.gnu.org>,
	<brian@talusmusic.com>,
	<gcc-bugs@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-gnats@gcc.gnu.org>
Cc:  
Subject: RE: c++/6774: printf("%lld") prints bad values
Date: Thu, 23 May 2002 10:58:12 -0400

 I think I now discovered the real problem.
 
      pthread_t     id;
 
      status = pthread_create(&id, ...)
 
   The first call to pthread_create returns a valid thread ID 'id' argument.
 Subsequent pthread_create calls return 0 for id.   'status' is 0 in each
 case indicating successful thread creation.  (My multithreaded program works
 fine with the exception of that thread id.)
 
    I use a C++ object for each thread.  I was setting my object's ID
 attribute to the 'id' argument returned by pthread_create.   This works for
 the first thread I create, but not for subsequent threads.
 
    When I was printing out the thread_id, (which I later cast to long long),
 I was using "%lld".   So I thought %lld was the problem.  Since that wasn't
 the problem, I think the problem is with pthread_create.
 
    pthread_self() always returns the correct ID.    I now use this function
 everytime I need the thread-id.
 
    Do you want me to file a separate bug report on this?     Or am I going
 nuts again?   :)    I am on Red Hat Linux on an Intel platform.   Same thing
 happens on Mandrake Linux on Intel.
 
 
 
 Brian
 brian@talusmusic.com
 
 
 
 
 -----Original Message-----
 From: rth@gcc.gnu.org [mailto:rth@gcc.gnu.org]
 Sent: Thursday, May 23, 2002 2:42 AM
 To: brian@talusmusic.com; gcc-bugs@gcc.gnu.org; gcc-prs@gcc.gnu.org;
 nobody@gcc.gnu.org
 Subject: Re: c++/6774: printf("%lld") prints bad values
 
 
 Synopsis: printf("%lld") prints bad values
 
 State-Changed-From-To: open->closed
 State-Changed-By: rth
 State-Changed-When: Wed May 22 23:42:06 2002
 State-Changed-Why:
     Buggy test case.  You have a typo in your printf format.
     Should be "1 << %lld = %lld".  Using -Wall would have
     pointed this out:
 
     z.c: In function `main':
     z.c:11: warning: int format, different type arg (arg 2)
 
 
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
 r=6774
 


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

* RE: c++/6774: printf("%lld") prints bad values
@ 2002-05-23  5:46 Brian Ceccarelli
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Ceccarelli @ 2002-05-23  5:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/6774; it has been noted by GNATS.

From: "Brian Ceccarelli" <brian@talusmusic.com>
To: <rth@gcc.gnu.org>,
	<brian@talusmusic.com>,
	<gcc-bugs@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-gnats@gcc.gnu.org>
Cc:  
Subject: RE: c++/6774: printf("%lld") prints bad values
Date: Thu, 23 May 2002 08:46:17 -0400

 Thank you.  I didn't think the previous %d would matter.  'i 'was printing
 fine.  I was interested in 'n'.    Just learned something.
 
 This test case wasn't exactly the problem I was having.   I must have a
 different problem in my program.    Thanks . . . and I am sorry for
 bothering you.
 
 
 Brian
 
 
 -----Original Message-----
 From: rth@gcc.gnu.org [mailto:rth@gcc.gnu.org]
 Sent: Thursday, May 23, 2002 2:42 AM
 To: brian@talusmusic.com; gcc-bugs@gcc.gnu.org; gcc-prs@gcc.gnu.org;
 nobody@gcc.gnu.org
 Subject: Re: c++/6774: printf("%lld") prints bad values
 
 
 Synopsis: printf("%lld") prints bad values
 
 State-Changed-From-To: open->closed
 State-Changed-By: rth
 State-Changed-When: Wed May 22 23:42:06 2002
 State-Changed-Why:
     Buggy test case.  You have a typo in your printf format.
     Should be "1 << %lld = %lld".  Using -Wall would have
     pointed this out:
 
     z.c: In function `main':
     z.c:11: warning: int format, different type arg (arg 2)
 
 
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
 r=6774
 


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

* Re: c++/6774: printf("%lld") prints bad values
@ 2002-05-22 23:42 rth
  0 siblings, 0 replies; 5+ messages in thread
From: rth @ 2002-05-22 23:42 UTC (permalink / raw)
  To: brian, gcc-bugs, gcc-prs, nobody

Synopsis: printf("%lld") prints bad values

State-Changed-From-To: open->closed
State-Changed-By: rth
State-Changed-When: Wed May 22 23:42:06 2002
State-Changed-Why:
    Buggy test case.  You have a typo in your printf format.
    Should be "1 << %lld = %lld".  Using -Wall would have 
    pointed this out:
    
    z.c: In function `main':
    z.c:11: warning: int format, different type arg (arg 2)
    
    

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6774


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

end of thread, other threads:[~2002-05-23 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-22 17:46 c++/6774: printf("%lld") prints bad values brian
2002-05-22 23:42 rth
2002-05-23  5:46 Brian Ceccarelli
2002-05-23  7:56 Brian Ceccarelli
2002-05-23  9:26 Richard Henderson

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).