public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/55422] New: gcc does not diagnose change of linkage for a function.
@ 2012-11-20 23:52 cookevillain at yahoo dot com
  2012-11-20 23:56 ` [Bug c/55422] " cookevillain at yahoo dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: cookevillain at yahoo dot com @ 2012-11-20 23:52 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55422
           Summary: gcc does not diagnose change of linkage for a
                    function.
    Classification: Unclassified
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: cookevillain@yahoo.com


compiling:
----------------------------
static void ff(int a) {

  return;

}

int f(void) {

  ff(0);
  int ff = 0;

  {

    extern void ff(int);

  }

  return ff;

}
----------------------------

with:
gcc -Wall -c ice.c
----------------------------

produces no diagnostic, however, clause 6.2.2(3) of the ISO standard requires
that the first declaration of ff results in ff having internal linkage; then,
since the file scope declaration is hidden, according to 6.2.2(4), ff's linkage
is now external.

gcc correctly diagnoses this in the code below, so it seems to be related to
the declaration of ff as a function. the standard makes no distinction between
these two cases though.

---------------------------

static int ff;

int f(void) {

  int ff = 0;

  {

    extern int ff;

  }

  return ff;

}


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

* [Bug c/55422] gcc does not diagnose change of linkage for a function.
  2012-11-20 23:52 [Bug c/55422] New: gcc does not diagnose change of linkage for a function cookevillain at yahoo dot com
@ 2012-11-20 23:56 ` cookevillain at yahoo dot com
  2012-11-21 11:30 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cookevillain at yahoo dot com @ 2012-11-20 23:56 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from cookevillain at yahoo dot com 2012-11-20 23:55:16 UTC ---
gcc -v output, omitted in the report:

-------------------------------------

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.4.3-4ubuntu5.1' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)


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

* [Bug c/55422] gcc does not diagnose change of linkage for a function.
  2012-11-20 23:52 [Bug c/55422] New: gcc does not diagnose change of linkage for a function cookevillain at yahoo dot com
  2012-11-20 23:56 ` [Bug c/55422] " cookevillain at yahoo dot com
@ 2012-11-21 11:30 ` mpolacek at gcc dot gnu.org
  2012-11-21 12:44 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2012-11-21 11:30 UTC (permalink / raw)
  To: gcc-bugs


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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> 2012-11-21 11:29:41 UTC ---
GCC 4.4.3 is unsupported.  But the behavior is the same as with trunk GCC.


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

* [Bug c/55422] gcc does not diagnose change of linkage for a function.
  2012-11-20 23:52 [Bug c/55422] New: gcc does not diagnose change of linkage for a function cookevillain at yahoo dot com
  2012-11-20 23:56 ` [Bug c/55422] " cookevillain at yahoo dot com
  2012-11-21 11:30 ` mpolacek at gcc dot gnu.org
@ 2012-11-21 12:44 ` mpolacek at gcc dot gnu.org
  2012-11-21 21:54 ` cookevillain at yahoo dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2012-11-21 12:44 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> 2012-11-21 12:44:31 UTC ---
Looks like the first example is just an undefined behavior in which case GCC
isn't obliged to issue an error.


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

* [Bug c/55422] gcc does not diagnose change of linkage for a function.
  2012-11-20 23:52 [Bug c/55422] New: gcc does not diagnose change of linkage for a function cookevillain at yahoo dot com
                   ` (2 preceding siblings ...)
  2012-11-21 12:44 ` mpolacek at gcc dot gnu.org
@ 2012-11-21 21:54 ` cookevillain at yahoo dot com
  2012-12-09  1:29 ` pinskia at gcc dot gnu.org
  2023-12-17 20:51 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cookevillain at yahoo dot com @ 2012-11-21 21:54 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from cookevillain at yahoo dot com 2012-11-21 21:53:48 UTC ---
(In reply to comment #3)
> Looks like the first example is just an undefined behavior in which case GCC
> isn't obliged to issue an error.

Quite true. I just thought that the diagnostic should be consistent. In
addition, it is rare to use extern at block scope but a function declaration is
automatically `extern'ed in such case so this linkage inconsistency is even
harder to spot without a diagnostic when the inner `extern' is omitted.


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

* [Bug c/55422] gcc does not diagnose change of linkage for a function.
  2012-11-20 23:52 [Bug c/55422] New: gcc does not diagnose change of linkage for a function cookevillain at yahoo dot com
                   ` (3 preceding siblings ...)
  2012-11-21 21:54 ` cookevillain at yahoo dot com
@ 2012-12-09  1:29 ` pinskia at gcc dot gnu.org
  2023-12-17 20:51 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-09  1:29 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-09 01:29:44 UTC ---
The first example is invalid C90 anyways:
t4.c:10:3: error: ISO C90 forbids mixed declarations and code [-Wpedantic]


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

* [Bug c/55422] gcc does not diagnose change of linkage for a function.
  2012-11-20 23:52 [Bug c/55422] New: gcc does not diagnose change of linkage for a function cookevillain at yahoo dot com
                   ` (4 preceding siblings ...)
  2012-12-09  1:29 ` pinskia at gcc dot gnu.org
@ 2023-12-17 20:51 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-17 20:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55422

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

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 111708 which is fixed on the trunk for GCC 14.

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

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

end of thread, other threads:[~2023-12-17 20:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-20 23:52 [Bug c/55422] New: gcc does not diagnose change of linkage for a function cookevillain at yahoo dot com
2012-11-20 23:56 ` [Bug c/55422] " cookevillain at yahoo dot com
2012-11-21 11:30 ` mpolacek at gcc dot gnu.org
2012-11-21 12:44 ` mpolacek at gcc dot gnu.org
2012-11-21 21:54 ` cookevillain at yahoo dot com
2012-12-09  1:29 ` pinskia at gcc dot gnu.org
2023-12-17 20:51 ` 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).