Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: double free Date: Fri, 02 Dec 2016 08:56:44 -0800 Organization: None to speak of Lines: 76 Message-ID: References: <87bn2317dl.fsf@bsb.me.uk> <87shvfyrq6.fsf@bsb.me.uk> <5c2dd4b1-c566-92a0-265c-7a7659e9bfeb@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="090cc7681cd75c4b27901d5937130ec3"; logging-data="27734"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19A1DEahQCuSMylbD4rMnFv" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:jSKh8s9nsPSxuUsfyTww2UDJNBs= sha1:7U9saS+GQPpZlPl7TBGDTDMf2Cw= Xref: csiph.com comp.lang.c:97888 "James R. Kuyper" writes: > On 12/02/2016 04:21 AM, Albert van der Horst wrote: > ... >> Now imagine that to avoid ambuigity C where such that those brackets for >> functions where underlined. >> Normal parenthesis are to be used for forcing the evaluation order >> in complicated expressions, lets call this grouping. >> >> Now you can choose normal parenthesis or underlined parentesis for >> ``sizeof'' , and both would feel wrong. The choice is impossible. > > True - if we're going to completely semantically distinguish all of the > different uses for parentheses in the C standard, the parentheses in > sizeof(int) (which are part of the sizeof syntax), should not only be > distinguished from the parentheses in puts("Hello, World!") (which are > part of the function call syntax), but also from the parentheses in > sizeof(a+b) (which are solely for grouping purposes). In fact there are, if I've counted correctly, 24 distinct uses of parentheses in the grammar, any of which could in principle have been defined to use some other symbol. The following is extracted from N1570 Annex A. primary-expression: ( expression ) generic-selection: _Generic ( assignment-expression , generic-assoc-list ) postfix-expression: postfix-expression ( argument-expression-list[opt] ) ( type-name ) { initializer-list } ( type-name ) { initializer-list , } unary-expression: sizeof ( type-name ) _Alignof ( type-name ) cast-expression: ( type-name ) cast-expression atomic-type-specifier: _Atomic ( type-name ) alignment-specifier: _Alignas ( type-name ) _Alignas ( constant-expression ) direct-declarator: identifier ( declarator ) direct-abstract-declarator: ( abstract-declarator ) static_assert-declaration: _Static_assert ( constant-expression , string-literal ) ; selection-statement: if ( expression ) statement if ( expression ) statement else statement iteration-statement: while ( expression ) statement do statement while ( expression ) ; for ( expression[opt] ; expression[opt] ; expression[opt] ) statement for ( declaration expression[opt] ; expression[opt] ) statement control-line: # define identifier lparen identifier-listopt ) # define identifier lparen ... ) replacement-list new-line # define identifier lparen identifier-list , ... ) (For the control-line productions, "lparen" is a ( character not immediately preceded by white-space.) The fact that a function call postfix-expression ( argument-expression-list[opt] ) and a sizeof expression sizeof ( type-name ) can be superficially similar *if* you ignore the fact that sizeof is a keyword is not particularly significant. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"