public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39134]  New: front end does not reject sizeof on function types
@ 2009-02-09  2:06 bje at gcc dot gnu dot org
  2009-02-09  9:31 ` [Bug c/39134] " schwab at suse dot de
  0 siblings, 1 reply; 2+ messages in thread
From: bje at gcc dot gnu dot org @ 2009-02-09  2:06 UTC (permalink / raw)
  To: gcc-bugs

The following:

#include <stddef.h>

void test(void)
{
        size_t s1 = sizeof(test);
        size_t s2 = sizeof(void (void));
}

should not compile with -std=c99. According to the C99 standard section
6.5.3.4.1 "The sizeof operator shall not be applied to an expression that has
function type or an incomplete type, to the parenthesized name of such a type,
or to an expression that designates a bit-field member."

I would expect gcc to produce an error in this case.  sizeof actually
returns 1 and no error.


-- 
           Summary: front end does not reject sizeof on function types
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bje at gcc dot gnu dot org
  GCC host triplet: powerpc64-linux


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


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

* [Bug c/39134] front end does not reject sizeof on function types
  2009-02-09  2:06 [Bug c/39134] New: front end does not reject sizeof on function types bje at gcc dot gnu dot org
@ 2009-02-09  9:31 ` schwab at suse dot de
  0 siblings, 0 replies; 2+ messages in thread
From: schwab at suse dot de @ 2009-02-09  9:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from schwab at suse dot de  2009-02-09 09:30 -------
This is a GCC extension, use -Wpointer-arith or -pedantic or -pedantic-errors.

$ gcc -c -std=c99 -pedantic-errors cast.c 
cast.c: In function &#8216;test&#8217;:
cast.c:6: error: invalid application of &#8216;sizeof&#8217; to a function type
cast.c:7: error: invalid application of &#8216;sizeof&#8217; to a function type


-- 

schwab at suse dot de changed:

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


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


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

end of thread, other threads:[~2009-02-09  9:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-09  2:06 [Bug c/39134] New: front end does not reject sizeof on function types bje at gcc dot gnu dot org
2009-02-09  9:31 ` [Bug c/39134] " schwab at suse dot de

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