From: "Martin Storsjö" <martin@martin.st>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] lavu/video_enc_params: Avoid relying on an undefined C construct
Date: Tue, 31 Jan 2023 14:37:26 +0200 (EET)
Message-ID: <efc3b0c2-f1bb-4f86-ac20-257ab5aacc3@martin.st> (raw)
In-Reply-To: <167403470618.4503.12268030759745953598@lain.khirnov.net>
On Wed, 18 Jan 2023, Anton Khirnov wrote:
> Quoting Martin Storsjö (2023-01-15 23:47:41)
>> The construct of using offsetof on a (potentially anonymous) struct
>> defined within the offsetof expression, while supported by all
>> current compilers, has been declared explicitly undefined by the
>> C standards committee [1].
>>
>> Current Clang git main got a patch [2] which changed this construct
>> into a hard error. It seems like this will be softened into a
>> warning [3] soon though, as it did break a fair number of projects.
>>
>> Nevertheless - in this particular case, it's trivial to fix the
>> code not to rely on the construct that the standards committee has
>> explicitly called out as undefined.
>>
>> [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
>> [2] https://github.com/llvm/llvm-project/commit/e327b52766ed497e4779f4e652b9ad237dfda8e6
>> [3] https://reviews.llvm.org/D133574#4053647
>>
>> Signed-off-by: Martin Storsjö <martin@martin.st>
>> ---
>> libavutil/video_enc_params.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c
>> index 54bfed0ed9..33592dc128 100644
>> --- a/libavutil/video_enc_params.c
>> +++ b/libavutil/video_enc_params.c
>> @@ -27,11 +27,11 @@
>> AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type,
>> unsigned int nb_blocks, size_t *out_size)
>> {
>> - const size_t blocks_offset = offsetof(
>> - struct {
>> - AVVideoEncParams p;
>> - AVVideoBlockParams b;
>> - }, b);
>> + struct TestStruct {
>> + AVVideoEncParams p;
>> + AVVideoBlockParams b;
>> + };
>> + const size_t blocks_offset = offsetof(struct TestStruct, b);
>> size_t size = blocks_offset;
>> AVVideoEncParams *par;
>>
>> --
>> 2.34.1
>
> LGTM
Thanks, pushed now.
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2023-01-31 12:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-15 22:47 Martin Storsjö
2023-01-18 9:38 ` Anton Khirnov
2023-01-31 12:37 ` Martin Storsjö [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=efc3b0c2-f1bb-4f86-ac20-257ab5aacc3@martin.st \
--to=martin@martin.st \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git