public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114849] New: Static function pointer
@ 2024-04-25  8:10 Manjunath.Bhavimani at elektrobit dot com
  2024-04-25  8:16 ` [Bug middle-end/114849] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Manjunath.Bhavimani at elektrobit dot com @ 2024-04-25  8:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114849

            Bug ID: 114849
           Summary: Static function pointer
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Manjunath.Bhavimani at elektrobit dot com
  Target Milestone: ---

Created attachment 58036
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58036&action=edit
Zip folder contains snippet and preprocessed *.c files

Hi,

I am using compiler v10.2 (v10.2_build_b1728_g5963bc8).

I observed some suspicious behavior in code compilation.

In my code, I have a static function with the same name in three different
files (Task1.c, Task2.c, and Task3.c). The static function is accessed through
a static volatile function pointer in respective files. The volatile qualifier
is added to avoid optimization. Each file has its own dedicated data section in
memory.

With gcc v10.2, I observed that the data section for all static variables of
Task2 file is initialized properly, but not for the other files (Task1 and
Task3).

As a result, our code crashes when the static function is accessed through the
static function pointer.

Reason: The static function pointer has an invalid address or is "0".

Our observation: When we moved to a higher version of gcc (i.e., v10.3), this
issue is not observed.

Kindly let us know if this issue is already known. If yes, could you please let
us know the right patch version for v10.2? Otherwise, this needs to be fixed in
v10.2.

Upgrading to the v10.3 toolchain is not within our project scope.

I have attached all files and snippets for your reference.

Note: I am working on SRAM; no flash is used, hence no data copy operation.

With Regards,

Manjunath Bhavimani

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-09  6:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25  8:10 [Bug c/114849] New: Static function pointer Manjunath.Bhavimani at elektrobit dot com
2024-04-25  8:16 ` [Bug middle-end/114849] " pinskia at gcc dot gnu.org
2024-04-25  8:19 ` Manjunath.Bhavimani at elektrobit dot com
2024-04-25  8:23 ` pinskia at gcc dot gnu.org
2024-04-25  9:57 ` Manjunath.Bhavimani at elektrobit dot com
2024-04-29 11:55 ` Manjunath.Bhavimani at elektrobit dot com
2024-04-29 12:26 ` Manjunath.Bhavimani at elektrobit dot com
2024-05-09  6:52 ` Manjunath.Bhavimani at elektrobit dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).