This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/70490] New: __atomic_load_n(const __int128 *, ...) generates CMPXCHG16B with no warning


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

            Bug ID: 70490
           Summary: __atomic_load_n(const __int128 *, ...) generates
                    CMPXCHG16B with no warning
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mdpoole at troilus dot org
  Target Milestone: ---

When compiling for x86-64 with the -mcx16 flag, there is no diagnostic for code
like this:

#include <sys/mman.h>
__int128 test(void)
{
    const void *ptr = mmap(0, 4096, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0);
    const __int128 *p_v = (const __int128 *)ptr;
    return __atomic_load_n(p_v, __ATOMIC_SEQ_CST);
}

The CMPXCHG16B instruction that is generated unconditionally attempts to write
to the address, which causes a fault at runtime.  When __atomic_load_n() uses
that instruction, it seems prudent to reject a const pointer as the first
argument.

Command line: gcc -Wall -Wextra -mcx16 -O2 -c atomic.c
First line of "gcc --version": gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]