mailing list of musl libc
 help / color / mirror / code / Atom feed
From: 樊鹏 <fanpeng@loongson.cn>
To: "Rich Felker" <dalias@libc.org>
Cc: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: [musl] Question about flexible array
Date: Mon, 17 Jun 2024 11:20:38 +0800 (GMT+08:00)	[thread overview]
Message-ID: <1d4aed0c.7c9e.190243604d7.Coremail.fanpeng@loongson.cn> (raw)

[-- Attachment #1: Type: text/plain, Size: 2139 bytes --]

hi,

In arch/loongarch64/bits/signal.h, I got some compiling errors about flexible array:

In file included from /usr/include/signal.h:48,
                 from /usr/include/ucontext.h:9,
                 from /home/alpine/aports/community/onetbb/src/oneTBB-2021.12.0/python/rml/../../src/tbb/co_context.h:52,
                 from /home/alpine/aports/community/onetbb/src/oneTBB-2021.12.0/python/rml/../../src/tbb/scheduler_common.h:27,
                 from /home/alpine/aports/community/onetbb/src/oneTBB-2021.12.0/python/rml/ipc_server.cpp:23:
/usr/include/bits/signal.h:35:23: error: flexible array member 'mcontext_t::__extcontext' not at end of 'struct tbb::detail::r1::coroutine_type'
   35 |         unsigned long __extcontext[] __attribute__((__aligned__(16)));
      |                       ^~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
ninja: subcommand failed
>>> ERROR: onetbb: build failed


The reason is a difference between gcc and g++:

Flexible array members are not officially part of C++.
Flexible array members were officially standardized in C99.

If *.cpp includes this header file, it may result in an error. I suggest to change it to size-zero array format.

Meanwhile, you can also consider the patch I attached.
Your opinions are welcome.

Thanks.

本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。 
This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it. 

[-- Attachment #2: LoongArch-change-flexible-array-format.diff --]
[-- Type: application/octet-stream, Size: 717 bytes --]

diff --git a/arch/loongarch64/bits/signal.h b/arch/loongarch64/bits/signal.h
index 5a9ed8c9..cefa9a61 100644
--- a/arch/loongarch64/bits/signal.h
+++ b/arch/loongarch64/bits/signal.h
@@ -24,7 +24,7 @@ struct sigcontext {
 	unsigned long sc_pc;
 	unsigned long sc_regs[32];
 	unsigned sc_flags;
-	unsigned long sc_extcontext[] __attribute__((__aligned__(16)));
+	unsigned long sc_extcontext[0] __attribute__((__aligned__(16)));
 };
 #endif
 
@@ -32,7 +32,7 @@ typedef struct {
 	unsigned long __pc;
 	unsigned long __gregs[32];
 	unsigned __flags;
-	unsigned long __extcontext[] __attribute__((__aligned__(16)));
+	unsigned long __extcontext[0] __attribute__((__aligned__(16)));
 } mcontext_t;
 
 struct sigaltstack {

             reply	other threads:[~2024-06-17  3:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17  3:20 樊鹏 [this message]
2024-06-17  4:29 ` Thorsten Glaser

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=1d4aed0c.7c9e.190243604d7.Coremail.fanpeng@loongson.cn \
    --to=fanpeng@loongson.cn \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).