[Bug c/112826] gcc rejects the valid code and reports undefined reference

2023-12-03 Thread jwzeng at nuaa dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112826

--- Comment #4 from Junwei Zeng  ---
Thank you for your explanation.

[Bug c/112826] gcc rejects the valid code and reports undefined reference

2023-12-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112826

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=14105

--- Comment #3 from Andrew Pinski  ---
Note PR 14105 is the opposite request but both are invalid as both behavior
with and without optimization is allowed by the C standard.

[Bug c/112826] gcc rejects the valid code and reports undefined reference

2023-12-02 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112826

Xi Ruoyao  changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED
 CC||xry111 at gcc dot gnu.org

--- Comment #2 from Xi Ruoyao  ---
N1570 6.9 p2:

"If an identifier declared with external linkage is used in an expression
(other than as part of the operand of a sizeof or _Alignof operator whose
result is an integer constant), somewhere in the entire program there shall be
exactly one external definition for the identifier"

and annex J.2 explicitly lists "An identifier with external linkage is used,
but in the program there does not exist exactly one external definition for the
identifier" as undefined behavior.

Note that you cannot interpret "used" as "really executed at runtime" because
it's impossible to solve halting problem, so such an "interpretation" will
render the entire standard nonsense.

[Bug c/112826] gcc rejects the valid code and reports undefined reference

2023-12-02 Thread arsen at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112826

Arsen Arsenović  changed:

   What|Removed |Added

 CC||arsen at gcc dot gnu.org

--- Comment #1 from Arsen Arsenović  ---
I can't assert the validity of this code, but -O1 does elide the function as
expected.