public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/52779] New: [4.6 only] LTO produces false warning with type merging
@ 2012-03-29 18:46 pinskia at gcc dot gnu.org
  2012-03-30  1:42 ` [Bug lto/52779] " pinskia at gcc dot gnu.org
  2012-03-30  9:11 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-03-29 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52779
           Summary: [4.6 only] LTO produces false warning with type
                    merging
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pinskia@gcc.gnu.org


Take the following three files:
--- t0.c ----
void g1 (void) {
    __builtin_printf("+++\n");
}
--- CUT ---
--- t1.c ---
 const char glbl_str4[] = "New";
--- CUT ---
--- t2.c ---
extern const char glbl_str4[];

void g0 (void) {
    f0(glbl_str4);
}
--- CUT ---
Using "gcc -flto -O3 -r -nostdlib t0.c t1.c t2.c" produces the following
warning:
t2.c:1:19: warning: type of ‘glbl_str4’ does not match original declaration
[enabled by default]
t1.c:1:13: note: previously declared here
---- CUT ----
Note the order of the files is required so is the semi unrelated t0.c file.


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

* [Bug lto/52779] [4.6 only] LTO produces false warning with type merging
  2012-03-29 18:46 [Bug lto/52779] New: [4.6 only] LTO produces false warning with type merging pinskia at gcc dot gnu.org
@ 2012-03-30  1:42 ` pinskia at gcc dot gnu.org
  2012-03-30  9:11 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-03-30  1:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-03-30 01:39:59 UTC ---
A better understanding of what happens.
Arrays in both the C and C++ front-end are treated in an interesting way.  The
array's main variant is the array of the element types' main variant.
That is the const char[4]'s main variant is char[4].  But when we doing the
folding for printf to puts, this no longer holds for that const char[4] type.  
So when we do the merging of the type const char[4] for the first TU to the
second one, we have created an array type with a main variant which is
different from what the C/C++ front-end produces.
And then comes the last TU, where we have this main variant that is different. 
So we warn that char and const char are different, even if we don't care about
them being different variants because the front-end does not.

4.7 fixes it by using types_compatible instead of gimple_types_compatible.  Now
we still have this main variant issue that is latent in 4.7 and above.  Should
we fix that issue or just ignore it and how it does not matter?


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

* [Bug lto/52779] [4.6 only] LTO produces false warning with type merging
  2012-03-29 18:46 [Bug lto/52779] New: [4.6 only] LTO produces false warning with type merging pinskia at gcc dot gnu.org
  2012-03-30  1:42 ` [Bug lto/52779] " pinskia at gcc dot gnu.org
@ 2012-03-30  9:11 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-30  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-30 09:10:47 UTC ---
There is a duplicate of this bug which was fixed for 4.7.  There is even a
testcase somewhere.  We can't fix this in 4.6, thus, fixed for 4.7.


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

end of thread, other threads:[~2012-03-30  9:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29 18:46 [Bug lto/52779] New: [4.6 only] LTO produces false warning with type merging pinskia at gcc dot gnu.org
2012-03-30  1:42 ` [Bug lto/52779] " pinskia at gcc dot gnu.org
2012-03-30  9:11 ` rguenth 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).