public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108341] New: argument to `__builtin_ctz` should be assumed non-zero
@ 2023-01-09 12:10 lh_mouse at 126 dot com
  2023-01-09 12:28 ` [Bug tree-optimization/108341] " marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: lh_mouse at 126 dot com @ 2023-01-09 12:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108341
           Summary: argument to `__builtin_ctz` should be assumed non-zero
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lh_mouse at 126 dot com
  Target Milestone: ---

Godbolt: https://gcc.godbolt.org/z/PrPP4v9z1


```
extern int r;

int
bz(int value)
  {
    r = __builtin_ctz(value);
    return value != 0;  // always true
  }
```


According to GCC manual, if the argument to `__builtin_ctz()` is zero then the
behavior is undefined, but GCC fails to assume that this function always
returns `1`. 

But I have read https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94801, not sure
whether it's related.

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

end of thread, other threads:[~2023-01-10  8:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 12:10 [Bug tree-optimization/108341] New: argument to `__builtin_ctz` should be assumed non-zero lh_mouse at 126 dot com
2023-01-09 12:28 ` [Bug tree-optimization/108341] " marxin at gcc dot gnu.org
2023-01-09 15:55 ` aldyh at gcc dot gnu.org
2023-01-09 16:22 ` pinskia at gcc dot gnu.org
2023-01-09 16:37 ` [Bug tree-optimization/108341] argument to `__builtin_ctz` should be assumed non-zero when CTZ_DEFINED_VALUE_AT_ZERO says it is undefined jakub at gcc dot gnu.org
2023-01-09 18:49 ` amacleod at redhat dot com
2023-01-09 19:02 ` aldyh at gcc dot gnu.org
2023-01-10  8:05 ` lh_mouse at 126 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).