public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/11783] New: type promotion for printf under gcc
@ 2003-08-03 13:25 achim dot gaedke at physik dot tu-darmstadt dot de
  2003-08-03 14:03 ` [Bug c/11783] " pinskia at physics dot uc dot edu
  0 siblings, 1 reply; 2+ messages in thread
From: achim dot gaedke at physik dot tu-darmstadt dot de @ 2003-08-03 13:25 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11783

           Summary: type promotion for printf under gcc
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: achim dot gaedke at physik dot tu-darmstadt dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

#include <stdio.h>

int main() {
  double x=5.4;
  size_t i=3;
  printf("%.2f\n",-i+x);
  return 0;
}

compiled with: /opt/gcc-3.3/bin/gcc test_printf.cc -o test_printf

does result 4294967298.40

Swapping the order of i and x, the expected result is returned.

#include <stdio.h>

int main() {
  double x=5.4;
  size_t i=3;
  printf("%.2f\n",x-i);
  return 0;
}

Output: 2.40

My system: Redhat 8.0 with glibc-2.3.2-4.80.6, fully patched
The compiler is built without extra options.


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

* [Bug c/11783] type promotion for printf under gcc
  2003-08-03 13:25 [Bug c/11783] New: type promotion for printf under gcc achim dot gaedke at physik dot tu-darmstadt dot de
@ 2003-08-03 14:03 ` pinskia at physics dot uc dot edu
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-03 14:03 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11783


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-03 14:03 -------
Not a bug as you are negativing an unsigned number and that number stays positive 
(because -unsigned = unsigned) so the number in this case will be large (-3U=
4294967293U).  So this is not a GCC bug at all.


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

end of thread, other threads:[~2003-08-03 14:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-03 13:25 [Bug c/11783] New: type promotion for printf under gcc achim dot gaedke at physik dot tu-darmstadt dot de
2003-08-03 14:03 ` [Bug c/11783] " pinskia at physics dot uc dot edu

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