Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You can't have everything... where would you put it? -- Steven Wright


devel / comp.lang.c / Re: on confusing procedure names with the address of procedures

SubjectAuthor
* on confusing procedure names with the address of proceduresMeredith Montgomery
+* Re: on confusing procedure names with the address of proceduresStefan Ram
|`- Re: on confusing procedure names with the address of proceduresKeith Thompson
+- Re: on confusing procedure names with the address of proceduresTim Rentsch
+* Re: on confusing procedure names with the address of proceduresManfred
|`* Re: on confusing procedure names with the address of proceduresJames Kuyper
| `* Re: on confusing procedure names with the address of proceduresManfred
|  `- Re: on confusing procedure names with the address of proceduresJames Kuyper
+- Re: on confusing procedure names with the address of proceduresBart
`- Re: on confusing procedure names with the address of proceduresNoob

1
on confusing procedure names with the address of procedures

<86bl37e49v.fsf@levado.to>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18829&group=comp.lang.c#18829

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Hu1f/gStftKYRp2bwzXADg.user.46.165.242.75.POSTED!not-for-mail
From: mmontgom...@levado.to (Meredith Montgomery)
Newsgroups: comp.lang.c
Subject: on confusing procedure names with the address of procedures
Date: Fri, 29 Oct 2021 21:37:48 -0300
Organization: Aioe.org NNTP Server
Message-ID: <86bl37e49v.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="5122"; posting-host="Hu1f/gStftKYRp2bwzXADg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:aokKqOuql7EyVj+MZjaYr9kyOM4=
 by: Meredith Montgomery - Sat, 30 Oct 2021 00:37 UTC

I wrote

--8<---------------cut here---------------start------------->8---
int main()
{ char c1;

printf("c1 is at %p\n", &c1);
printf("and the addr of the addr of c1 is at %p\n", &&c1);
} --8<---------------cut here---------------end--------------->8---

and I didn't this to make any sense. Indeed, I get

--8<---------------cut here---------------start------------->8---
%make nonsense
gcc nonsense.c -o nonsense
nonsense.c: In function 'main':
nonsense.c:12:3: error: label 'c1' used but not defined
12 | printf("c1 is at %p\n", &&c1);
| ^~~~~~
make: *** [<builtin>: nonsense] Error 1
% --8<---------------cut here---------------end--------------->8---

The error message totally lost me.

But then I wrote

--8<---------------cut here---------------start------------->8---
#include <stdio.h>
int main()
{ printf("main is at %p\n", main);
printf("main is at %p\n", &main);
} --8<---------------cut here---------------end--------------->8---

and I expected a compilation error of some sort, but I got

--8<---------------cut here---------------start------------->8---
%CFLAGS=-Wall make main-addr
gcc -Wall main-addr.c -o main-addr

%./main-addr.exe
main is at 00007ff617431594
main is at 00007ff617431594
% --8<---------------cut here---------------end--------------->8---

So main must be stored at 00007ff617431594 and so it becomes unintuitive
that getting the address of main yields the same value.

My interpretation of this last program is that

main = &main

but for the first program

&c1 =/= & &c1

because the right side is nonsensical? It's trying to get the address
of an address, when we should only get the address of a name. Can't get
the address of numbers.

Pretty confusing.

Re: on confusing procedure names with the address of procedures

<address-of-20211030021305@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18830&group=comp.lang.c#18830

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: 30 Oct 2021 01:13:42 GMT
Organization: Stefan Ram
Lines: 18
Expires: 1 Dec 2021 11:59:58 GMT
Message-ID: <address-of-20211030021305@ram.dialup.fu-berlin.de>
References: <86bl37e49v.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de zBUefLypBUve80F5nn/TUQiVMAGaLomPwL1msIT8DVmn9V
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Sat, 30 Oct 2021 01:13 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
>printf("and the addr of the addr of c1 is at %p\n", &&c1);

The operand of the unary & operator shall be either a
function designator, the result of a [] or unary * operator,
or an /lvalue/ that designates an object that is * not a
bit-field and is not declared with the register
storage-class specifier.

The unary & operator yields the /address/ of its operand.
Such an address is a mere data value, not an object.
It is not an lvalue. So it does not have an address.
So, one cannot use "&&c1".

Therefore, the GNU compiler uses "&&" as its notation to
take the address of a /label/, but this is not standard C.

Re: on confusing procedure names with the address of procedures

<878rybz4dv.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18831&group=comp.lang.c#18831

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: Fri, 29 Oct 2021 18:29:48 -0700
Organization: None to speak of
Lines: 42
Message-ID: <878rybz4dv.fsf@nosuchdomain.example.com>
References: <86bl37e49v.fsf@levado.to>
<address-of-20211030021305@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="679ddad86518bcd07b55dfd2beeff025";
logging-data="14946"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hd2ISmSAEsKlfGzTMylgJ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:y36N2FVMH1VhbZMq43wAkMoXMno=
sha1:fWgcaPKvMS+uKYiopXcwQS++lrs=
 by: Keith Thompson - Sat, 30 Oct 2021 01:29 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Meredith Montgomery <mmontgomery@levado.to> writes:
>>printf("and the addr of the addr of c1 is at %p\n", &&c1);
>
> The operand of the unary & operator shall be either a
> function designator, the result of a [] or unary * operator,
> or an /lvalue/ that designates an object that is * not a
> bit-field and is not declared with the register
> storage-class specifier.
>
> The unary & operator yields the /address/ of its operand.
> Such an address is a mere data value, not an object.
> It is not an lvalue. So it does not have an address.
> So, one cannot use "&&c1".
>
> Therefore, the GNU compiler uses "&&" as its notation to
> take the address of a /label/, but this is not standard C.

And gcc does this because "&&" is already a token (the logical "and"
operator). Since C uses the "maximal munch" rule, the sequence
&&c
is tokenized as "&&" followed by "c". If it were legal to apply unary "&"
to a unary "&" operation you'd have to write it as:
& &c
or
&(&c)

That would probably give you (Meredith) an error message closer to what
you were expecting.

The "maximal munch" rule is why
x+++++y
is tokenized as
x ++ ++ + y
(a syntax error) rather than as
x ++ + ++ y
(which could be a valid expression).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: on confusing procedure names with the address of procedures

<86fssje1p7.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18832&group=comp.lang.c#18832

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: Fri, 29 Oct 2021 18:33:24 -0700
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <86fssje1p7.fsf@linuxsc.com>
References: <86bl37e49v.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="6172d9893ff5ddcd59d33e927dfcf2b5";
logging-data="13150"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xck4xKO8N+DbNy02HJRy/yvcUODC+3Zo="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:izKBo76saJZuuGqgKVNyo7Qf5WA=
sha1:mxcP6vb+Q1oPCxOm0bR6+hDGlkU=
 by: Tim Rentsch - Sat, 30 Oct 2021 01:33 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:

> I wrote
>
> [..various confusions..]

I recommend:

One: get in the habit of running gcc in a conforming mode -

gcc -x c -std=c99 -pedantic-errors <whatever>.c

Two: get a copy of the C standard (or a close approximation thereto)

wget http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

(This link is for a corrected draft of C99. It isn't the latest
version of C but for starters it is an excellent reference.)

Three: read section 6.3.2.1 paragraphs 1, 3, and 4.

Four: read section 6.5.3.2

Five: after reading the above and looking again at your code,
if you are still confused ask another question here.

Six: in general, if there is ever a question or confusion you
have about C, first try to find the answer yourself in the
document whose link is given above. If you feel you still
need help then ask in the newsgroup here.

Re: on confusing procedure names with the address of procedures

<sliebn$16l6$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18834&group=comp.lang.c#18834

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: Sat, 30 Oct 2021 05:32:07 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sliebn$16l6$1@gioia.aioe.org>
References: <86bl37e49v.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="39590"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.2.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Sat, 30 Oct 2021 03:32 UTC

On 10/30/2021 2:37 AM, Meredith Montgomery wrote:
> I wrote
>
> --8<---------------cut here---------------start------------->8---
> int main()
> {
> char c1;
>
> printf("c1 is at %p\n", &c1);
> printf("and the addr of the addr of c1 is at %p\n", &&c1);
> }
> --8<---------------cut here---------------end--------------->8---
>
> and I didn't this to make any sense. Indeed, I get
>
> --8<---------------cut here---------------start------------->8---
> %make nonsense
> gcc nonsense.c -o nonsense
> nonsense.c: In function 'main':
> nonsense.c:12:3: error: label 'c1' used but not defined
> 12 | printf("c1 is at %p\n", &&c1);
> | ^~~~~~
> make: *** [<builtin>: nonsense] Error 1
> %
> --8<---------------cut here---------------end--------------->8---
>
> The error message totally lost me.
>
> But then I wrote
>
> --8<---------------cut here---------------start------------->8---
> #include <stdio.h>
> int main()
> {
> printf("main is at %p\n", main);
> printf("main is at %p\n", &main);
> }
> --8<---------------cut here---------------end--------------->8---
>
> and I expected a compilation error of some sort, but I got
>
> --8<---------------cut here---------------start------------->8---
> %CFLAGS=-Wall make main-addr
> gcc -Wall main-addr.c -o main-addr
>
> %./main-addr.exe
> main is at 00007ff617431594
> main is at 00007ff617431594
> %
> --8<---------------cut here---------------end--------------->8---
>
> So main must be stored at 00007ff617431594 and so it becomes unintuitive
> that getting the address of main yields the same value.

In expressions where the function name is used (but not as a call to
that function, so not main()), the function is automatically converted
to a pointer to function (similar to arrays that decay to pointers in
many circumstances). So using main and &main as argument to printf
indeed yields the same result: the address of main.
The same applies to the inverse case, if you have a pointer to function:

#include <stdio.h>

void bar()
{ printf("hello\n");
}

int main()
{ void (*foo)() = bar;

// You can execute the call in both of the following ways:

foo(); // the pointer is implicitly dereferenced
(*foo)(); // the pointer is explicitly dereferenced
}

>
> My interpretation of this last program is that
>
> main = &main
>
> but for the first program
>
> &c1 =/= & &c1
>
> because the right side is nonsensical? It's trying to get the address
> of an address, when we should only get the address of a name. Can't get
> the address of numbers.

As a rationale, addresses represent memory locations (for functions it
is a bit more complicated than that, so let's stick to data for this
second part). This means that an address may be taken from objects that
have some memory storage, e.g. c1.
The result of &c1 is indeed a pure value which has no memory storage, so
its address cannot be taken (in fact it may be physically stored in a
register and not in any memory location, but even if it were stored
somewhere in memory, you would miss some identification of that memory
location in order to get its address).

>
> Pretty confusing.
>

Yet pointers and addresses are probably amongst the most powerful
features of C.

Re: on confusing procedure names with the address of procedures

<slil2c$pke$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18835&group=comp.lang.c#18835

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: Sat, 30 Oct 2021 01:26:35 -0400
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <slil2c$pke$1@dont-email.me>
References: <86bl37e49v.fsf@levado.to> <sliebn$16l6$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 30 Oct 2021 05:26:36 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="35b62fe080287f5b9d1a01c4724946e9";
logging-data="26254"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18i+uqWuDJsZXIMK/6K9qMQzrtOtIPYyjU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:l4fPAVpRZ7t9WbveJ7kYaR/w4us=
In-Reply-To: <sliebn$16l6$1@gioia.aioe.org>
Content-Language: en-US
 by: James Kuyper - Sat, 30 Oct 2021 05:26 UTC

On 10/29/21 11:32 PM, Manfred wrote:
....
> In expressions where the function name is used (but not as a call to
> that function, so not main()), the function is automatically converted
> to a pointer to function (similar to arrays that decay to pointers in
> many circumstances).

The rule you're referring to is "A function designator is an expression
that has function type. Except when it is the operand of the sizeof
operator, 69) or the unary & operator, a function designator with type
"function returning type" is converted to an expression that has type
"pointer to function returning type"." (6.3.2.1p4).
The "69)" refers to footnote 69, which points out that "Because this
conversion does not occur, the operand of the sizeof operator remains a
function designator and violates the constraints in 6.5.3.4."

Note that the only exceptions to that rule are for sizeof and &; there
is no exception to that rule for actual function calls. That's good,
because the standard imposes a constraint: "The expression that denotes
the called function 102) shall have type pointer to function returning
void or returning a complete object type other than an array type."
(6.5.5.2p1). If it weren't for that automatic conversion, a call to main
would require the following syntax: "(&main)()".

Note that this is a change that occurred in C90. K&R C had no such
conversion, and specified that "A function call is a primary expression
followed by parentheses ... The primary expression must be of type
"function returning ...""
The conversion and the constraint were both introduced when C was first
standardized, so that main() remained a valid function call, albeit for
different reasons, both in K&R C and in C90.

The purpose of the change was to simplify the use of function pointers.
Before the change, they had to be called using (*function_pointer)().
That remains a valid expression, since *function_pointer is an
expression of function type, which automatically gets converted back to
a pointer, but they can now also be called more directly by using
function_pointer().

....
> void (*foo)() = bar;
>
> // You can execute the call in both of the following ways:
>
> foo(); // the pointer is implicitly dereferenced

That hasn't been true since C90.

Re: on confusing procedure names with the address of procedures

<slj77j$ufg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18836&group=comp.lang.c#18836

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: Sat, 30 Oct 2021 11:36:34 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <slj77j$ufg$1@dont-email.me>
References: <86bl37e49v.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 30 Oct 2021 10:36:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1e5cb410d6b3762b4b6665d5b1b0a87e";
logging-data="31216"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5X1P+Blm0syPGaAC8eRB5e8nyVP7jVF8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.2.1
Cancel-Lock: sha1:/MZjaXtvILJqL6uDgMKiBmVKSlg=
In-Reply-To: <86bl37e49v.fsf@levado.to>
 by: Bart - Sat, 30 Oct 2021 10:36 UTC

On 30/10/2021 01:37, Meredith Montgomery wrote:

> 12 | printf("c1 is at %p\n", &&c1);

&& is used for label address with some C implementations. Label c1
doesn't exist. (Variable c1 does, but in C, variables and labels live in
different namespaces; the same names can coexist).

> printf("main is at %p\n", main);
> printf("main is at %p\n", &main);
> }

If you have a function F, then:

F() Calls the function
F Yields its address
&F Yields its address

So F and &F do the same thing. In effect, the first line could also be
written as:

(&F)() Calls the function

Re: on confusing procedure names with the address of procedures

<slju07$1ghj$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18839&group=comp.lang.c#18839

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: Sat, 30 Oct 2021 19:05:12 +0200
Organization: Aioe.org NNTP Server
Message-ID: <slju07$1ghj$1@gioia.aioe.org>
References: <86bl37e49v.fsf@levado.to> <sliebn$16l6$1@gioia.aioe.org>
<slil2c$pke$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="49715"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.2.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Manfred - Sat, 30 Oct 2021 17:05 UTC

On 10/30/2021 7:26 AM, James Kuyper wrote:
> On 10/29/21 11:32 PM, Manfred wrote:
> ...
>> In expressions where the function name is used (but not as a call to
>> that function, so not main()), the function is automatically converted
>> to a pointer to function (similar to arrays that decay to pointers in
>> many circumstances).
>
> The rule you're referring to is "A function designator is an expression
> that has function type. Except when it is the operand of the sizeof
> operator, 69) or the unary & operator, a function designator with type
> "function returning type" is converted to an expression that has type
> "pointer to function returning type"." (6.3.2.1p4).
> The "69)" refers to footnote 69, which points out that "Because this
> conversion does not occur, the operand of the sizeof operator remains a
> function designator and violates the constraints in 6.5.3.4."
>
> Note that the only exceptions to that rule are for sizeof and &; there
> is no exception to that rule for actual function calls. That's good,
> because the standard imposes a constraint: "The expression that denotes
> the called function 102) shall have type pointer to function returning
> void or returning a complete object type other than an array type."
> (6.5.5.2p1). If it weren't for that automatic conversion, a call to main
> would require the following syntax: "(&main)()".
>
> Note that this is a change that occurred in C90. K&R C had no such
> conversion, and specified that "A function call is a primary expression
> followed by parentheses ... The primary expression must be of type
> "function returning ...""
> The conversion and the constraint were both introduced when C was first
> standardized, so that main() remained a valid function call, albeit for
> different reasons, both in K&R C and in C90.
>
> The purpose of the change was to simplify the use of function pointers.
> Before the change, they had to be called using (*function_pointer)().
> That remains a valid expression, since *function_pointer is an
> expression of function type, which automatically gets converted back to
> a pointer, but they can now also be called more directly by using
> function_pointer().
>

Thanks for the detailed reference to the standard.

> ...
>> void (*foo)() = bar;
>>
>> // You can execute the call in both of the following ways:
>>
>> foo(); // the pointer is implicitly dereferenced
>
> That hasn't been true since C90.
>

I guess you mean that the pointer is not "dereferenced", but still the
expression is a valid call to the function, so the statement "You can
execute the call in both ways" still holds.

Re: on confusing procedure names with the address of procedures

<slk5nr$km2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18842&group=comp.lang.c#18842

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: Sat, 30 Oct 2021 15:17:15 -0400
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <slk5nr$km2$1@dont-email.me>
References: <86bl37e49v.fsf@levado.to> <sliebn$16l6$1@gioia.aioe.org>
<slil2c$pke$1@dont-email.me> <slju07$1ghj$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 30 Oct 2021 19:17:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="35b62fe080287f5b9d1a01c4724946e9";
logging-data="21186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193EUNNMyGPW6bZZ4EoCm33yLPsuW7jBQs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:3XzChx9zaJuieAik63WDsaHUgKM=
In-Reply-To: <slju07$1ghj$1@gioia.aioe.org>
Content-Language: en-US
 by: James Kuyper - Sat, 30 Oct 2021 19:17 UTC

On 10/30/21 1:05 PM, Manfred wrote:
> On 10/30/2021 7:26 AM, James Kuyper wrote:
>> On 10/29/21 11:32 PM, Manfred wrote:
....
>>> void (*foo)() = bar;
>>>
>>> // You can execute the call in both of the following ways:
>>>
>>> foo(); // the pointer is implicitly dereferenced
>>
>> That hasn't been true since C90.
>>
>
> I guess you mean that the pointer is not "dereferenced", ...

Correct.

> ... but still the
> expression is a valid call to the function, so the statement "You can
> execute the call in both ways" still holds.

Yes. I didn't think about the possibility that I could have been
interpreted as disagreeing with both comments.

Re: on confusing procedure names with the address of procedures

<slol20$rh5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18845&group=comp.lang.c#18845

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: roo...@127.0.0.1 (Noob)
Newsgroups: comp.lang.c
Subject: Re: on confusing procedure names with the address of procedures
Date: Mon, 1 Nov 2021 13:03:12 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <slol20$rh5$1@dont-email.me>
References: <86bl37e49v.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 1 Nov 2021 12:03:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2d32a28baf70354daba57af3592c285d";
logging-data="28197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/b+tkFi/sNh/ilWcm/JFQ0OUDiY26H3Hk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:aBs8KE+TuSt/OU0mcOhhkBy9hso=
In-Reply-To: <86bl37e49v.fsf@levado.to>
Content-Language: en-US
 by: Noob - Mon, 1 Nov 2021 12:03 UTC

On 30/10/2021 02:37, Meredith Montgomery wrote:

> gcc nonsense.c -o nonsense
> nonsense.c: In function 'main':
> nonsense.c:12:3: error: label 'c1' used but not defined
> 12 | printf("c1 is at %p\n", &&c1);
> | ^~~~~~

As Tim pointed out, your command-line lacks the proper flags to put
GCC in (mostly) conformant mode, and print useful diagnostics.

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

CFLAGS = -std=c17 -pedantic-errors -Wpedantic -Wall -Werror

Regards.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor