Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: memcpy not memcpying? Date: Mon, 04 Nov 2019 10:03:28 -0800 Organization: None to speak of Lines: 31 Message-ID: References: <2LVuF.7$BF1.0@fx26.iad> <6KfvF.57888$rJ1.57717@fx01.am4> <0DivF.23103$Q26.16540@fx34.am4> <1BAvF.13970$mB7.12243@fx32.am4> <%%DvF.115593$Yl3.480@fx24.am4> <87eeynlwc7.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="81eacac46dc9725928a0db9ff018e2c7"; logging-data="3298"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ok/nFrcTA040rOaeQzHgJ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:CGHaWuQhUt5VQDeRHQLACw/pG7U= sha1:jRZoju2+yOz9bwIaP/7Inf1CREM= Xref: csiph.com comp.lang.c:147585 Ben Bacarisse writes: [...] > I think I might use _Generic here because checking the size is not > always going to be enough: > > _Static_assert( > _Generic(i, int: 1, default: 0), > "Check this because symbolcount_t is not compatible with int." > ); > > This works (in both clang and gcc) with -std=c11 -pedantic, but I am not > sure that _Generic /must/ be allowed here. It would be a shame if > generic selections were not considered to be standard constant > expressions. Have I missed something in the standard? I think it's covered in 6.6, which has this contraint in p2: Constant expressions shall not contain assignment, increment, decrement, function-call, or comma operators, except when they are contained within a subexpression that is not evaluated. Which implies, I think, that a generic selection is a constant expression if the result expression is a constant expression, even if the other subexpressions are not. gcc and clang seem to agree. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */