public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/51983] New: Wrong line number in an uninitialized variable warning
@ 2012-01-24 19:52 Greta.Yorsh at arm dot com
  2012-01-24 20:10 ` [Bug c/51983] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: Greta.Yorsh at arm dot com @ 2012-01-24 19:52 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51983
           Summary: Wrong line number in an uninitialized variable warning
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: Greta.Yorsh@arm.com
                CC: ramana@gcc.gnu.org


For uninitialized variables of type _Complex, arm and x86 compilers report
different line numbers in warning messages:
* if only the real part of a complex variable is uninitialized, arm compiler
reports the line number where the variable is declared.
* if only the imaginary part of a complex variable is uninitialized, arm
compiler reports the line number where the variable is used.
* if only one of the parts of a complex variable is uninitialized, x86 compiler
reports the line where the other part is initialized.
* if both parts of a complex variable are uninitialized, both arm and x86
compilers (correctly) report the line where the variable is used. 

This behaviour causes a failure in gcc.dg/uninit-13.c test on arm target. 

Note that in this test, dg-warning directive expects the warning message about
uninitialized variable to report the line in which the imaginary part of the
complex variable is initialized, and not the line where the uninitialized
variable is used. That is, the test passes on x86 target, even thought the line
number in the message is not what one would (perhaps naively) expect, based on
the behaviour of the compiler for other types of uninitialized variables.

I don't know if the problem is in the frontend, middle-end, target, or
testsuite. 


----------------------------------------
$ cat -n /work/tmp/unin1.c 
     1    typedef _Complex float C;
     2    C foo(int *p)
     3    {
     4      C f;
     5      int a = *p;
     6      *p = 42 * a;
     7      __imag__ f = 0;
     8      return f;
     9    }

$ arm-none-eabi-gcc -O -Wuninitialized -S    -o tmp.s  /work/tmp/unin1.c
/work/tmp/unin1.c: In function 'foo':
/work/tmp/unin1.c:4:5: warning: '__real__ f' is used uninitialized in this
function [-Wuninitialized]

$ gcc -O -Wuninitialized -S    -o tmp.s  /work/tmp/unin1.c
/work/tmp/unin1.c: In function ‘foo’:
/work/tmp/unin1.c:7: warning: ‘__real__ f’ is used uninitialized in this
function

----------------------------------------
$ cat -n /work/tmp/unin2.c 
     1    typedef _Complex float C;
     2    C foo(int *p)
     3    {
     4      C f;
     5      int a = *p;
     6      *p = 42 * a;
     7      __real__ f = 0;
     8      return f;
     9    }

$ arm-none-eabi-gcc -O -Wuninitialized -S    -o tmp.s  /work/tmp/unin2.c
/work/tmp/unin2.c: In function 'foo':
/work/tmp/unin2.c:8:3: warning: '__imag__ f' is used uninitialized in this
function [-Wuninitialized]

$ gcc -O -Wuninitialized -S    -o tmp.s  /work/tmp/unin2.c
/work/tmp/unin2.c: In function ‘foo’:
/work/tmp/unin2.c:7: warning: ‘__imag__ f’ is used uninitialized in this
function
----------------------------------------
$ cat -n /work/tmp/unin3.c 
     1    typedef _Complex float C;
     2    C foo(int *p)
     3    {
     4      C f;
     5      int a = *p;
     6      *p = 42 * a;
     7    
     8      return f;
     9    }
$ arm-none-eabi-gcc -O -Wuninitialized -S    -o tmp.s  /work/tmp/unin3.c
/work/tmp/unin3.c: In function 'foo':
/work/tmp/unin3.c:8:3: warning: 'f' is used uninitialized in this function
[-Wuninitialized]

$ gcc -O -Wuninitialized -S    -o tmp.s  /work/tmp/unin3.c
/work/tmp/unin3.c: In function ‘foo’:
/work/tmp/unin3.c:8: warning: ‘f’ is used uninitialized in this function


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

* [Bug c/51983] Wrong line number in an uninitialized variable warning
  2012-01-24 19:52 [Bug c/51983] New: Wrong line number in an uninitialized variable warning Greta.Yorsh at arm dot com
@ 2012-01-24 20:10 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-24 20:10 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-24 19:48:24 UTC ---
Dup of bug 39246.

*** This bug has been marked as a duplicate of bug 39246 ***


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

end of thread, other threads:[~2012-01-24 19:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 19:52 [Bug c/51983] New: Wrong line number in an uninitialized variable warning Greta.Yorsh at arm dot com
2012-01-24 20:10 ` [Bug c/51983] " pinskia at gcc dot gnu.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).