This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/120: Re: Switching 'cast to union' off?



>Number:         120
>Category:       c++
>Synopsis:       Switching 'cast to union' off?
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    unassigned
>State:          analyzed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 17 12:26:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Dirk Herrmann <dirk@ida.ing.tu-bs.de>
>Release:        2.95.2
>Organization:
>Environment:
>Description:
 Date: Fri, 17 Mar 2000 11:31:50 +0100 (MET)
 Original-Message-ID: <Pine.LNX.4.21.0003171118150.1999-100000@marvin.ida.ing.tu-bs.de>

 We have code that does _not_ produce a warning, but we rather want a
 warning produced.

 Example code:

 ----------------------------------
 typedef union { long n; } SCM;

 int main()
 {
     SCM x;
     long y;

     x = (SCM)y;   /* This is a misuse of type SCM (also, not allowed by
		   /* ANSI).  However, the compiler accepts it. */

     return 0;
 }
 ----------------------------------

 I tried egcs-2.91.66 (Suse 6.3 linux) and gcc 2.95.2 (solaris 7).  Both
 show the same behaviour.  Compiler options were:  gcc -Wall test.c
 With gcc -Wall -pedantic test.c we get:
   test.c: In function `main':
   test.c:8: warning: ANSI C forbids casts to union type
 However, -pedantic also reports lots of other ansi violations that are not
 of importance for us (like use of asm commands).  Thus, we don't want to
 require users to have to enable -pedantic to find the casting problem
 described above.

 In general, I think, it would be nice to be able to switch of each of the
 GNU extensions by compiler options separately.

>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]