public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/40786]  New: Windows %I32 format confusion
@ 2009-07-17 15:59 jsm28 at gcc dot gnu dot org
  2009-07-19  8:55 ` [Bug target/40786] " ktietz at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-07-17 15:59 UTC (permalink / raw)
  To: gcc-bugs

http://msdn.microsoft.com/en-us/library/tcxf1dw6(VS.71).aspx
says that the Windows %I32 printf formats take arguments of type __int32
or unsigned __int32.

config/i386/msformat-c.c defines these using FMT_LEN_l, i.e. type long.
It appears that MinGW uses long for __int32, but MinGW-W64 uses int
(despite long being 32-bit for Win64), and so the compiler should
distinguish between these cases - or, in this special case, allow both
types.  (I don't know what __int32 is with the MS compiler, for either
32-bit or 64-bit.)

The testcase gcc.dg/format/ms-format1.c passes an int value to this format,
and so fails.  sys_format.c passes a long value, and so passes.  Clearly
both should pass the same type.


-- 
           Summary: Windows %I32 format confusion
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org
GCC target triplet: *-*-mingw*


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
@ 2009-07-19  8:55 ` ktietz at gcc dot gnu dot org
  2009-07-19  9:34 ` sezeroz at gmail dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu dot org @ 2009-07-19  8:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from ktietz at gcc dot gnu dot org  2009-07-19 08:55 -------
I agree, that the behavior isn't correct here. %I32 is treated at the moment as
equivalent for %l width specifier. But in fact is the type __int32 specifying
an integer scalar with 32-bit width. For x86 and x64, where
sizeof(long)==sizeof(int), the %I32 should be valid for both, or just for
integer. That it is interpreted as equivalent to %l is indeed a bug.

Cheers,
Kai


-- 

ktietz at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-07-19 08:55:12
               date|                            |


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
  2009-07-19  8:55 ` [Bug target/40786] " ktietz at gcc dot gnu dot org
@ 2009-07-19  9:34 ` sezeroz at gmail dot com
  2009-08-18 11:32 ` ktietz at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sezeroz at gmail dot com @ 2009-07-19  9:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from sezeroz at gmail dot com  2009-07-19 09:33 -------
Problem also exists in 4.4.0/4.4.1.


-- 

sezeroz at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sezeroz at gmail dot com


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
  2009-07-19  8:55 ` [Bug target/40786] " ktietz at gcc dot gnu dot org
  2009-07-19  9:34 ` sezeroz at gmail dot com
@ 2009-08-18 11:32 ` ktietz at gcc dot gnu dot org
  2009-08-21 19:22 ` ktietz at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu dot org @ 2009-08-18 11:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ktietz at gcc dot gnu dot org  2009-08-18 11:32 -------
Is there a way to make %I32 accepting both types?
Something like FMT_LEN_z?


-- 


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-08-18 11:32 ` ktietz at gcc dot gnu dot org
@ 2009-08-21 19:22 ` ktietz at gcc dot gnu dot org
  2009-08-22 10:07 ` ktietz at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu dot org @ 2009-08-21 19:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ktietz at gcc dot gnu dot org  2009-08-21 19:22 -------
As to see on Wiki
http://en.wikipedia.org/wiki/Printf#printf_format_placeholders

%I32 means, for integer types, causes to expect a 32-bit (double word) integer
argument. May tests have shown that long type and int type arguments are valid
here.


-- 


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-08-21 19:22 ` ktietz at gcc dot gnu dot org
@ 2009-08-22 10:07 ` ktietz at gcc dot gnu dot org
  2009-08-22 16:44 ` joseph at codesourcery dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu dot org @ 2009-08-22 10:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ktietz at gcc dot gnu dot org  2009-08-22 10:07 -------
Created an attachment (id=18412)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18412&action=view)
Suggested patch

This patch can solve this. There are two possible ways to solve this.
First) Extend format_length_info by an new field to specify if identity in size
is ok for check.
Second) Do the check within the format_length_info loop and check here for
I32/I64.

This patch implements solution 2.

Any comments on it?

Cheers,
Kai


-- 


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-08-22 10:07 ` ktietz at gcc dot gnu dot org
@ 2009-08-22 16:44 ` joseph at codesourcery dot com
  2009-08-22 17:31 ` ktietz at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: joseph at codesourcery dot com @ 2009-08-22 16:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from joseph at codesourcery dot com  2009-08-22 16:43 -------
Subject: Re:  Windows %I32 format confusion

On Sat, 22 Aug 2009, ktietz at gcc dot gnu dot org wrote:

> This patch can solve this. There are two possible ways to solve this.
> First) Extend format_length_info by an new field to specify if identity in size
> is ok for check.
> Second) Do the check within the format_length_info loop and check here for
> I32/I64.
> 
> This patch implements solution 2.
> 
> Any comments on it?

I believe the first solution is better.  We generally try to avoid 
hardcoded references to particular formats, length specifiers etc. within 
the checking code.


-- 


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-08-22 16:44 ` joseph at codesourcery dot com
@ 2009-08-22 17:31 ` ktietz at gcc dot gnu dot org
  2009-08-23 11:00 ` ktietz at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu dot org @ 2009-08-22 17:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from ktietz at gcc dot gnu dot org  2009-08-22 17:30 -------
Created an attachment (id=18414)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18414&action=view)
Patch using format_length_info member variable

Ok, here is the version using format_length_info to marked the scalar identity 


-- 


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-08-22 17:31 ` ktietz at gcc dot gnu dot org
@ 2009-08-23 11:00 ` ktietz at gcc dot gnu dot org
  2009-08-24  6:20 ` ktietz at gcc dot gnu dot org
  2009-10-30 17:52 ` ktietz at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu dot org @ 2009-08-23 11:00 UTC (permalink / raw)
  To: gcc-bugs



-- 

ktietz at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ktietz at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-08-23 11:00 ` ktietz at gcc dot gnu dot org
@ 2009-08-24  6:20 ` ktietz at gcc dot gnu dot org
  2009-10-30 17:52 ` ktietz at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu dot org @ 2009-08-24  6:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from ktietz at gcc dot gnu dot org  2009-08-24 06:20 -------
Patch fixed for 4.5 at revision 151047.

I would like to backport this patch to 4.4 and possibly to 4.3 branch, too?


-- 


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


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

* [Bug target/40786] Windows %I32 format confusion
  2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-08-24  6:20 ` ktietz at gcc dot gnu dot org
@ 2009-10-30 17:52 ` ktietz at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: ktietz at gcc dot gnu dot org @ 2009-10-30 17:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ktietz at gcc dot gnu dot org  2009-10-30 17:52 -------
Well, I meant of course 4.4 branch. I won't backport this. So I closed this
bug.


-- 

ktietz at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2009-10-30 17:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-17 15:59 [Bug target/40786] New: Windows %I32 format confusion jsm28 at gcc dot gnu dot org
2009-07-19  8:55 ` [Bug target/40786] " ktietz at gcc dot gnu dot org
2009-07-19  9:34 ` sezeroz at gmail dot com
2009-08-18 11:32 ` ktietz at gcc dot gnu dot org
2009-08-21 19:22 ` ktietz at gcc dot gnu dot org
2009-08-22 10:07 ` ktietz at gcc dot gnu dot org
2009-08-22 16:44 ` joseph at codesourcery dot com
2009-08-22 17:31 ` ktietz at gcc dot gnu dot org
2009-08-23 11:00 ` ktietz at gcc dot gnu dot org
2009-08-24  6:20 ` ktietz at gcc dot gnu dot org
2009-10-30 17:52 ` ktietz at gcc dot gnu dot org

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