public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/9166: [2003-01-03] C front end's type scoping not right
@ 2003-01-08  1:03 bangerth
  0 siblings, 0 replies; 5+ messages in thread
From: bangerth @ 2003-01-08  1:03 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, neil, nobody

Synopsis: [2003-01-03] C front end's type scoping not right

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Tue Jan  7 17:03:54 2003
State-Changed-Why:
    This has been analyzed before. For completeness, here's what
    icc7 says:
    tmp/g> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -std=c99 -c -pedantic x.c
    x.c: In function `foo':
    x.c:5: warning: `struct bar' declared inside parameter list
    x.c:5: warning: its scope is only this definition or declaration, which is probably not what you want
    tmp/g> icc x.c
    x.c(5): warning #274: declaration is not visible outside of function
        extern void f( struct bar {double x, y;} );
                              ^
    
    x.c(8): warning #159: declaration is incompatible with previous "f" (declared at line 5)
      void f (struct bar );
           ^
    
    From the discussion, this should really be a change-request
    than a bug report.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9166


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

* Re: c/9166: [2003-01-03] C front end's type scoping not right
@ 2003-03-01  8:37 neil
  0 siblings, 0 replies; 5+ messages in thread
From: neil @ 2003-03-01  8:37 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, neil, nobody

Synopsis: [2003-01-03] C front end's type scoping not right

State-Changed-From-To: analyzed->closed
State-Changed-By: neil
State-Changed-When: Sat Mar  1 08:37:01 2003
State-Changed-Why:
    Submitter no longer considers this important.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9166


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

* Re: c/9166: [2003-01-03] C front end's type scoping not right
@ 2003-01-04 13:36 Neil Booth
  0 siblings, 0 replies; 5+ messages in thread
From: Neil Booth @ 2003-01-04 13:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/9166; it has been noted by GNATS.

From: Neil Booth <neil@daikokuya.co.uk>
To: "Joseph S. Myers" <jsm28@cam.ac.uk>
Cc: neil@gcc.gnu.org, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Subject: Re: c/9166: [2003-01-03] C front end's type scoping not right
Date: Sat, 4 Jan 2003 13:27:10 +0000

 Joseph S. Myers wrote:-
 
 > What makes you think the former prototype is visible at the latter?  The
 > former declaration has block scope; as the Rationale discusses, there is a
 > delibrate compromise in the standard here, where a former block scope
 > external declaration can be considered, but need not be.  Incompatible
 > declarations need only be diagnosed in the same scope (by 6.7#4).  
 > Declarations refering to the same object or function that are not in the
 > same scope merely yield undefined behavior if of incompatible types
 > (6.2.7#2).
 
 Fair enough.  Obviously I'd never considered the former declaration
 visible, it clearly isn't.  I'd just not read the consequences of
 incompatible declarations closely enough.
 
 I think a pedwarn would be nice, though I suspect it's hard with GCC's
 current code.
 
 At least the behaviour is better than EDG and LCC, which always reject the
 second declaration as incompatible even when it's identical.
 
 Neil.


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

* Re: c/9166: [2003-01-03] C front end's type scoping not right
@ 2003-01-04 11:26 Joseph S. Myers
  0 siblings, 0 replies; 5+ messages in thread
From: Joseph S. Myers @ 2003-01-04 11:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/9166; it has been noted by GNATS.

From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: <neil@gcc.gnu.org>
Cc: <gcc-gnats@gcc.gnu.org>,  <gcc-bugs@gcc.gnu.org>
Subject: Re: c/9166: [2003-01-03] C front end's type scoping not right
Date: Sat, 4 Jan 2003 11:24:42 +0000 (GMT)

 On 4 Jan 2003 neil@gcc.gnu.org wrote:
 
 > /* Compile the code snippet below with -pedantic.  The code is illegal
 > because the function f is redeclared with an incompatible prototype,
 > but GCC doesn't winge.  */
 > 
 > struct bar {int x, y;};
 > 
 > void foo ()
 > {
 >   extern void f( struct bar {double x, y;} );
 > }
 > 
 > void f (struct bar );
 
 What makes you think the former prototype is visible at the latter?  The
 former declaration has block scope; as the Rationale discusses, there is a
 delibrate compromise in the standard here, where a former block scope
 external declaration can be considered, but need not be.  Incompatible
 declarations need only be diagnosed in the same scope (by 6.7#4).  
 Declarations refering to the same object or function that are not in the
 same scope merely yield undefined behavior if of incompatible types
 (6.2.7#2).  That said, a mandatory pedwarn for a latter declaration 
 incompatible with a former invisible declaration would make sense, but 
 there is no bug here and the former declaration shouldn't be considered 
 visible for most ordinary purposes (seeing whether the function is 
 declared when it is used, converting arguments, etc.) - just to complain 
 about the incompatibility with another declaration.
 
 -- 
 Joseph S. Myers
 jsm28@cam.ac.uk
 


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

* c/9166: [2003-01-03] C front end's type scoping not right
@ 2003-01-04  0:36 neil
  0 siblings, 0 replies; 5+ messages in thread
From: neil @ 2003-01-04  0:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9166
>Category:       c
>Synopsis:       [2003-01-03] C front end's type scoping not right
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 03 16:36:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     neil@gcc.gnu.org
>Release:        GCC 3.4 and earlier
>Organization:
>Environment:

>Description:
/* Compile the code snippet below with -pedantic.  The code
is illegal because the function f is redeclared with an incompatible prototype, but GCC doesn't winge.  */

struct bar {int x, y;};

void foo ()
{
  extern void f( struct bar {double x, y;} );
}

void f (struct bar );
>How-To-Repeat:

>Fix:
I doubt it's easy with the current code.  Best idea is to clean up the front-end's handling of scopes; it's too messy and obfuscated.
>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2003-03-01  8:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-08  1:03 c/9166: [2003-01-03] C front end's type scoping not right bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-03-01  8:37 neil
2003-01-04 13:36 Neil Booth
2003-01-04 11:26 Joseph S. Myers
2003-01-04  0:36 neil

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