Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #1795

Re: Conversion from void* to pointer-to-function?

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.std.c
Subject Re: Conversion from void* to pointer-to-function?
Date 2012-12-21 17:58 -0800
Organization None to speak of
Message-ID <lnip7uq24k.fsf@nuthaus.mib.org> (permalink)
References <ln62af6sum.fsf@nuthaus.mib.org> <kfnsj6z7qkv.fsf@x-alumni2.alumni.caltech.edu> <lntxrfpvvf.fsf@nuthaus.mib.org> <kfnfw2z75ap.fsf@x-alumni2.alumni.caltech.edu>

Show all headers | View raw


Tim Rentsch <txr@alumni.caltech.edu> writes:
> Keith Thompson <kst-u@mib.org> writes:
[...]
>> gcc issues mere warnings for a lot of things that are constraint
>> violations.  [snip elaboration]
>
> That's good to know, but I'm not sure it changes my reaction.
> Do you have some other examples readily at hand?

$ cat c.c
int main(void) {
    int x;
    int y = &x;
    main + 1;
    sizeof (void);
}
$ gcc -c -std=c11 -pedantic -c c.c
c.c: In function ‘main’:
c.c:3:13: warning: initialization makes integer from pointer without a cast [enabled by default]
c.c:4:10: warning: pointer to a function used in arithmetic [-pedantic]
c.c:5:13: warning: invalid application of ‘sizeof’ to a void type [-pedantic]
$ gcc -c -std=c11 -pedantic-errors -c c.c
c.c: In function ‘main’:
c.c:3:13: error: initialization makes integer from pointer without a cast
c.c:4:10: error: pointer to a function used in arithmetic [-pedantic]
c.c:5:13: error: invalid application of ‘sizeof’ to a void type
[-pedantic]
$ 

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.std.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Conversion from void* to pointer-to-function? Keith Thompson <kst-u@mib.org> - 2012-06-25 13:26 -0700
  Re: Conversion from void* to pointer-to-function? James Kuyper <jameskuyper@verizon.net> - 2012-06-25 17:23 -0400
    Re: Conversion from void* to pointer-to-function? Keith Thompson <kst-u@mib.org> - 2012-06-25 14:57 -0700
      Re: Conversion from void* to pointer-to-function? Maxim Fomin <maxim@maxim-fomin.ru> - 2012-06-27 10:03 -0700
        Re: Conversion from void* to pointer-to-function? Keith Thompson <kst-u@mib.org> - 2012-06-27 11:33 -0700
          Re: Conversion from void* to pointer-to-function? David R Tribble <david@tribble.com> - 2012-07-24 20:05 -0700
  Re: Conversion from void* to pointer-to-function? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-21 00:32 -0800
    Re: Conversion from void* to pointer-to-function? Tijl Coosemans <tijl@coosemans.org> - 2012-12-21 10:00 +0100
    Re: Conversion from void* to pointer-to-function? Keith Thompson <kst-u@mib.org> - 2012-12-21 02:01 -0800
      Re: Conversion from void* to pointer-to-function? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-21 08:12 -0800
        Re: Conversion from void* to pointer-to-function? Keith Thompson <kst-u@mib.org> - 2012-12-21 17:58 -0800
          Re: Conversion from void* to pointer-to-function? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-22 08:22 -0800

csiph-web