public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/20655] New: Attempt to use undefined structure tag triggers no diagnostic
@ 2005-03-27 15:33 jozef dot behran at krs dot sk
  2005-03-27 16:15 ` [Bug c/20655] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jozef dot behran at krs dot sk @ 2005-03-27 15:33 UTC (permalink / raw)
  To: gcc-bugs

/*** SNIP ***/  
/*  
  Place this file into `bug.c' (the code between the SNIP comments).  
  Then try `gcc -c -Wall bug.c'  
  The compiler silently transforms the type of the structure component 
  below to some kind of a generic pointer or something. 
  However it should output a diagnostic on the `UndefinedTag' identifier, 
  especially when -Wall is specified (as you can see above).  
  It is OK what the compiler does with this code but a warning should be  
  produced when the user really cares about them.  
  Without such a warning things often become confusing when someone  
  changes the tag in the declaration and forgets to update the tag name  
  in the pointers.  
*/  
  
typedef struct tagType {  
  struct UndefinedTag *Pointer;  
} TType;  
  
/*** SNIP ***/

-- 
           Summary: Attempt to use undefined structure tag triggers no
                    diagnostic
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jozef dot behran at krs dot sk
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c/20655] Attempt to use undefined structure tag triggers no diagnostic
  2005-03-27 15:33 [Bug c/20655] New: Attempt to use undefined structure tag triggers no diagnostic jozef dot behran at krs dot sk
@ 2005-03-27 16:15 ` pinskia at gcc dot gnu dot org
  2005-04-01 19:49 ` jozef dot behran at krs dot sk
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-27 16:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-27 16:15 -------
This is still valid code because the struct could be defined below still.
For an example:
struct a
{
  struct b *c;
};

struct b
{
  int i;
  struct a *c;
};

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


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


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

* [Bug c/20655] Attempt to use undefined structure tag triggers no diagnostic
  2005-03-27 15:33 [Bug c/20655] New: Attempt to use undefined structure tag triggers no diagnostic jozef dot behran at krs dot sk
  2005-03-27 16:15 ` [Bug c/20655] " pinskia at gcc dot gnu dot org
@ 2005-04-01 19:49 ` jozef dot behran at krs dot sk
  2005-04-01 20:19 ` joseph at codesourcery dot com
  2005-04-01 20:58 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jozef dot behran at krs dot sk @ 2005-04-01 19:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jozef dot behran at krs dot sk  2005-04-01 19:49 -------
> This is still valid code because the struct could be defined below still. 
 
But if the struct is not defined anywhere (not even below its use), a warning should 
occur. If you send the first declaration to the compiler without sending the second 
one, you should see a warning about an undeclared structure. However if you 
send your example to the compiler as you mentioned it, no warnings should 
appear. This warning should at least indicate the users that there may be 
something wrong with their code and that they should check for typos or so. 
Note that the code is valid, but unusual. If you see a structure tag used 
somewhere without being declared, most likely it is a bug in the code. Otherwise 
the compiler may give the user very strange error/warning messages that may 
confuse him seriously (a structure type seeming not to be compatible with itself). 

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


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


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

* [Bug c/20655] Attempt to use undefined structure tag triggers no diagnostic
  2005-03-27 15:33 [Bug c/20655] New: Attempt to use undefined structure tag triggers no diagnostic jozef dot behran at krs dot sk
  2005-03-27 16:15 ` [Bug c/20655] " pinskia at gcc dot gnu dot org
  2005-04-01 19:49 ` jozef dot behran at krs dot sk
@ 2005-04-01 20:19 ` joseph at codesourcery dot com
  2005-04-01 20:58 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: joseph at codesourcery dot com @ 2005-04-01 20:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From joseph at codesourcery dot com  2005-04-01 20:19 -------
Subject: Re:  Attempt to use undefined structure tag triggers
 no diagnostic

On Fri, 1 Apr 2005, jozef dot behran at krs dot sk wrote:

> Note that the code is valid, but unusual. If you see a structure tag used 
> somewhere without being declared, most likely it is a bug in the code. Otherwise 

No, if a tag is used without the structure or union contents being defined 
then most likely it is being used as an opaque type and the definition is 
in a separate internal header for e.g. the library implementation but does 
not form part of the public interface.



-- 


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


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

* [Bug c/20655] Attempt to use undefined structure tag triggers no diagnostic
  2005-03-27 15:33 [Bug c/20655] New: Attempt to use undefined structure tag triggers no diagnostic jozef dot behran at krs dot sk
                   ` (2 preceding siblings ...)
  2005-04-01 20:19 ` joseph at codesourcery dot com
@ 2005-04-01 20:58 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-01 20:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-01 20:58 -------
If you deference or do an assignment like:

TType *a, *b;
....
b->Pointer = a;

You will either get an error or a warning saying the code is invalid.

Also as mentioned by JSM, it is a way to provide opaque type pointers.

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


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


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

end of thread, other threads:[~2005-04-01 20:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-27 15:33 [Bug c/20655] New: Attempt to use undefined structure tag triggers no diagnostic jozef dot behran at krs dot sk
2005-03-27 16:15 ` [Bug c/20655] " pinskia at gcc dot gnu dot org
2005-04-01 19:49 ` jozef dot behran at krs dot sk
2005-04-01 20:19 ` joseph at codesourcery dot com
2005-04-01 20:58 ` pinskia 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).