public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36685] clarify/diagnose use of weak constant
       [not found] <bug-36685-4@http.gcc.gnu.org/bugzilla/>
@ 2022-05-25 15:06 ` foom at fuhm dot net
  2022-05-25 15:13 ` foom at fuhm dot net
  1 sibling, 0 replies; 4+ messages in thread
From: foom at fuhm dot net @ 2022-05-25 15:06 UTC (permalink / raw)
  To: gcc-bugs

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

James Y Knight <foom at fuhm dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |foom at fuhm dot net

--- Comment #4 from James Y Knight <foom at fuhm dot net> ---
The interaction of __attribute__((weak)) and const int was recently explored in
Clang in this thread:
https://discourse.llvm.org/t/weak-attribute-semantics-on-const-variables/62311

Strangely, it appears that Clang and GCC have opposite odd behavior currently:
GCC appears to evaluate weak constants _only_ in constant evaluation (so long
as

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

* [Bug c++/36685] clarify/diagnose use of weak constant
       [not found] <bug-36685-4@http.gcc.gnu.org/bugzilla/>
  2022-05-25 15:06 ` [Bug c++/36685] clarify/diagnose use of weak constant foom at fuhm dot net
@ 2022-05-25 15:13 ` foom at fuhm dot net
  1 sibling, 0 replies; 4+ messages in thread
From: foom at fuhm dot net @ 2022-05-25 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from James Y Knight <foom at fuhm dot net> ---
(oops submitted commit by mistake, continuing...)

Strangely, it appears that Clang and GCC both have odd behaviors currently, but
somewhat opposites:

- GCC appears to evaluate weak constants _only_ in frontend constant
evaluation. It does not treat them as known during backend optimizations.
(However, GCC does not allow you to use such a variable in a context that is
required to be constant by language rules).

- Clang evaluates weak constants _only_ in backend optimizations, and never in
frontend constant evaluation.


Clang will be changing to stop optimizing based on weak constant value, so that
they are consistently treated as unknown values.

I'd suggest that GCC probably ought to do the same (by no longer constant
evaluating such variables).

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

* [Bug c++/36685] clarify/diagnose use of weak constant
  2008-07-01 10:02 [Bug c++/36685] New: " algrant at acm dot org
  2008-07-01 10:22 ` [Bug c++/36685] " algrant at acm dot org
@ 2008-07-01 11:36 ` joseph at codesourcery dot com
  1 sibling, 0 replies; 4+ messages in thread
From: joseph at codesourcery dot com @ 2008-07-01 11:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from joseph at codesourcery dot com  2008-07-01 11:35 -------
Subject: Re:   New: clarify/diagnose use of weak constant

See the inconclusive discussion at 
<http://gcc.gnu.org/ml/gcc-patches/2008-05/subjects.html#00451> (the 
original message was the previous month), and bug 35501.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36685


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

* [Bug c++/36685] clarify/diagnose use of weak constant
  2008-07-01 10:02 [Bug c++/36685] New: " algrant at acm dot org
@ 2008-07-01 10:22 ` algrant at acm dot org
  2008-07-01 11:36 ` joseph at codesourcery dot com
  1 sibling, 0 replies; 4+ messages in thread
From: algrant at acm dot org @ 2008-07-01 10:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from algrant at acm dot org  2008-07-01 10:21 -------
Similar argument applies to __attribute__((visibility("default"))) .


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36685


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

end of thread, other threads:[~2022-05-25 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-36685-4@http.gcc.gnu.org/bugzilla/>
2022-05-25 15:06 ` [Bug c++/36685] clarify/diagnose use of weak constant foom at fuhm dot net
2022-05-25 15:13 ` foom at fuhm dot net
2008-07-01 10:02 [Bug c++/36685] New: " algrant at acm dot org
2008-07-01 10:22 ` [Bug c++/36685] " algrant at acm dot org
2008-07-01 11:36 ` joseph at codesourcery 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).