public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113599] New: Wrong computation of member offset through pointer-to-member
@ 2024-01-25 12:37 simon.marchi at polymtl dot ca
  2024-01-25 12:39 ` [Bug c++/113599] [14 Regression] Wrong computation of member offset through pointer-to-member since r14-5503 jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: simon.marchi at polymtl dot ca @ 2024-01-25 12:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113599
           Summary: Wrong computation of member offset through
                    pointer-to-member
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon.marchi at polymtl dot ca
  Target Milestone: ---

This commit:

  c++: non-dependent .* operand folding [PR112427] 
  https://gitlab.com/gnutools/gcc/-/commit/d3f48f68227

seems to cause a regression in some cases when computing the address of a
member using a pointer-to-member.

Origin: https://sourceware.org/bugzilla/show_bug.cgi?id=31281

I made this reproducer, which was then made more minimal by Tom de Vries.  We
get the address of the thread_info::node field in two different ways.  One
using through a pointer-to-member, the other is getting its address directly. 
We expect both to be equal.  gcc 14/trunk gets it wrong.

...
struct intrusive_list_node {
  void *next;
};

struct dummy {
  void *base;
};

struct thread_info : public dummy, public intrusive_list_node {
  intrusive_list_node node;
};

static thread_info ti;

int main (void) {
  auto thread_info::*MemberNode = &thread_info::node;
  auto node_ptr_1 = &(ti.*MemberNode);
  auto node_ptr_2 = &ti.node;
  return !(node_ptr_1 == node_ptr_2);
}
...

gcc-13:
...
$ g++ test.cpp; ./a.out; echo $?
0
...

gcc-14:
...
$ g++ test.cpp; ./a.out; echo $?
1
...

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

end of thread, other threads:[~2024-01-25 23:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25 12:37 [Bug c++/113599] New: Wrong computation of member offset through pointer-to-member simon.marchi at polymtl dot ca
2024-01-25 12:39 ` [Bug c++/113599] [14 Regression] Wrong computation of member offset through pointer-to-member since r14-5503 jakub at gcc dot gnu.org
2024-01-25 12:49 ` vries at gcc dot gnu.org
2024-01-25 13:06 ` jakub at gcc dot gnu.org
2024-01-25 13:24 ` jakub at gcc dot gnu.org
2024-01-25 14:48 ` ppalka at gcc dot gnu.org
2024-01-25 23:09 ` cvs-commit at gcc dot gnu.org
2024-01-25 23:09 ` jakub at gcc dot gnu.org

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).