public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [Bug default/26739] New: Handle qualified typedef array types
@ 2020-10-15 18:21 gprocida+abigail at google dot com
  2020-10-23 16:36 ` [Bug default/26739] " dodji at redhat dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gprocida+abigail at google dot com @ 2020-10-15 18:21 UTC (permalink / raw)
  To: libabigail

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

            Bug ID: 26739
           Summary: Handle qualified typedef array types
           Product: libabigail
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: default
          Assignee: dodji at redhat dot com
          Reporter: gprocida+abigail at google dot com
                CC: libabigail at sourceware dot org
  Target Milestone: ---

The C language has a "feature" I believe also inherited by C++.

Array and function types cannot be CV-qualified. You can try with typedefs and
results are... non-obvious. Typedefs are *not* simply aliases.

If a typedef is qualified and it refers to a function type, then undefined
behaviour ensues. (WAT? Not legal, not illegal, not implementation-defined...
undefined.)

If a typedef is qualified and it refers to an array type, then the qualified
typedef resolves not necessarily to the original array type, but to a similar
one where the element types gain the qualifiers on the typedef. (WAT?!)

This means building C types requires a degree of evaluation rather than just
plain construction.

Unsurprisingly, this is confusing both to humans and to libabigail. The code
below has no ABI change, as member q is const int[7] in both versions. However,
abidiff reports things which may or may not be strictly true.

It's quite possible that the DWARF for these mutant typedefs is "interesting"
and I wouldn't be surprised if GCC and Clang have differences here. (GCC
already copies element type qualifiers to the array types, Clang does not).

==> mutant_typedef_arrays_c.0.c <==
typedef const int immutable[7];
typedef immutable monster;

struct A {
  monster q;
};

void fun(struct A * a) { (void) a; }

==> mutant_typedef_arrays_c.1.c <==
typedef int plain[7];
typedef const plain monster;

struct A {
  monster q;
};

void fun(struct A * a) {
  (void) a;
  // assignment to read-only location
  // a->q[0] = 0;
}

$ abidiff --no-show-locs mutant_typedef_arrays_c.?.o 
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

1 function with some indirect sub-type change:

  [C] 'function void fun(A*)' has some indirect sub-type changes:
    parameter 1 of type 'A*' has sub-type changes:
      in pointed to type 'struct A':
        type size hasn't changed
        1 data member change:
          type of 'const monster A::q' changed:
            in unqualified underlying type 'typedef monster':
              underlying type 'typedef immutable' changed:
                entity changed from 'typedef immutable' to compatible type
'int[7]'
                  array element type 'const int' changed:
                    entity changed from 'const int' to 'int'
                    type size hasn't changed
                  type name changed from 'const int[7]' to 'int[7]'
                  type size hasn't changed

$ echo $?
4

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug default/26739] Handle qualified typedef array types
  2020-10-15 18:21 [Bug default/26739] New: Handle qualified typedef array types gprocida+abigail at google dot com
@ 2020-10-23 16:36 ` dodji at redhat dot com
  2020-10-27 17:22 ` dodji at redhat dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dodji at redhat dot com @ 2020-10-23 16:36 UTC (permalink / raw)
  To: libabigail

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

dodji at redhat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-10-23

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug default/26739] Handle qualified typedef array types
  2020-10-15 18:21 [Bug default/26739] New: Handle qualified typedef array types gprocida+abigail at google dot com
  2020-10-23 16:36 ` [Bug default/26739] " dodji at redhat dot com
@ 2020-10-27 17:22 ` dodji at redhat dot com
  2020-11-09 14:35 ` dodji at redhat dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dodji at redhat dot com @ 2020-10-27 17:22 UTC (permalink / raw)
  To: libabigail

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

--- Comment #1 from dodji at redhat dot com ---
Thank you for taking the time to report this problem.

I posted a patch (for review) to the mailing list that should hopefully handle
this issue.

It can be read at
https://sourceware.org/pipermail/libabigail/2020q4/002779.html.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug default/26739] Handle qualified typedef array types
  2020-10-15 18:21 [Bug default/26739] New: Handle qualified typedef array types gprocida+abigail at google dot com
  2020-10-23 16:36 ` [Bug default/26739] " dodji at redhat dot com
  2020-10-27 17:22 ` dodji at redhat dot com
@ 2020-11-09 14:35 ` dodji at redhat dot com
  2020-11-09 14:35 ` dodji at redhat dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dodji at redhat dot com @ 2020-11-09 14:35 UTC (permalink / raw)
  To: libabigail

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

--- Comment #2 from dodji at redhat dot com ---
I posted an updated patch at html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug default/26739] Handle qualified typedef array types
  2020-10-15 18:21 [Bug default/26739] New: Handle qualified typedef array types gprocida+abigail at google dot com
                   ` (2 preceding siblings ...)
  2020-11-09 14:35 ` dodji at redhat dot com
@ 2020-11-09 14:35 ` dodji at redhat dot com
  2020-11-13 17:10 ` dodji at redhat dot com
  2020-12-04 17:09 ` gprocida+abigail at google dot com
  5 siblings, 0 replies; 7+ messages in thread
From: dodji at redhat dot com @ 2020-11-09 14:35 UTC (permalink / raw)
  To: libabigail

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

--- Comment #3 from dodji at redhat dot com ---
Sorry, I meant I posted an updated patch at
https://sourceware.org/pipermail/libabigail/2020q4/002810.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug default/26739] Handle qualified typedef array types
  2020-10-15 18:21 [Bug default/26739] New: Handle qualified typedef array types gprocida+abigail at google dot com
                   ` (3 preceding siblings ...)
  2020-11-09 14:35 ` dodji at redhat dot com
@ 2020-11-13 17:10 ` dodji at redhat dot com
  2020-12-04 17:09 ` gprocida+abigail at google dot com
  5 siblings, 0 replies; 7+ messages in thread
From: dodji at redhat dot com @ 2020-11-13 17:10 UTC (permalink / raw)
  To: libabigail

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

dodji at redhat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |NOTABUG
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from dodji at redhat dot com ---
This one has been committed at
https://sourceware.org/git/?p=libabigail.git;a=commit;h=3c87247cb42a3d3d8f57b02ded34c35284aea51a
and should be available in libabigail 1.8.

Thanks for taking the time to report this problem!

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug default/26739] Handle qualified typedef array types
  2020-10-15 18:21 [Bug default/26739] New: Handle qualified typedef array types gprocida+abigail at google dot com
                   ` (4 preceding siblings ...)
  2020-11-13 17:10 ` dodji at redhat dot com
@ 2020-12-04 17:09 ` gprocida+abigail at google dot com
  5 siblings, 0 replies; 7+ messages in thread
From: gprocida+abigail at google dot com @ 2020-12-04 17:09 UTC (permalink / raw)
  To: libabigail

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

Giuliano Procida <gprocida+abigail at google dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|NOTABUG                     |---

--- Comment #5 from Giuliano Procida <gprocida+abigail at google dot com> ---
Hi Dodji.

Please take a look at
https://sourceware.org/pipermail/libabigail/2020q4/002992.html. I used GCC
10.2.0.

This is actually a test case I came up with to exercise BTF (pahole / libbtf).

This is an area where, until we check and verify otherwise, no part of the
toolchain should be beyond suspicion.

However, we are definitely seeing some incorrect reporting here.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2020-12-04 17:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15 18:21 [Bug default/26739] New: Handle qualified typedef array types gprocida+abigail at google dot com
2020-10-23 16:36 ` [Bug default/26739] " dodji at redhat dot com
2020-10-27 17:22 ` dodji at redhat dot com
2020-11-09 14:35 ` dodji at redhat dot com
2020-11-09 14:35 ` dodji at redhat dot com
2020-11-13 17:10 ` dodji at redhat dot com
2020-12-04 17:09 ` gprocida+abigail at google 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).