[LLVMbugs] [Bug 20688] New: _Alignas handling rejects tentative definitions with no alignment specifier

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Aug 16 17:12:07 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20688

            Bug ID: 20688
           Summary: _Alignas handling rejects tentative definitions with
                    no alignment specifier
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

There is a rule in C11 subclause 6.7.5 paragraph 7 that if the definition of an
object does not have an alignment specifier, then any other declaration of that
object shall also have no alignment specifier.

Clang attempts to produce a diagnostic for that rule although it is not a
constraint (that is, no diagnostic is required). Unfortunately, the
implementation of the diagnostic is problematic. It treats tentative
definitions as definitions in their own right.

The ability for there to be multiple tentative definitions for the same object
means that applying the rule regarding "the" definition upon a tentative
definition does not make sense.

### SOURCE:
$ cat tentativeDefinitionNotADefinition.c 
char _Alignas(int) c = 'a';
char c;


### COMPILER INVOCATION AND OUTPUT:
$ clang -cc1 -x c -std=c11 tentativeDefinitionNotADefinition.c 
tentativeDefinitionNotADefinition.c:2:6: error: '_Alignas' must be specified on
definition if it is specified on any declaration
char c;
     ^
tentativeDefinitionNotADefinition.c:1:6: note: declared with '_Alignas'
attribute here
char _Alignas(int) c = 'a';
     ^
1 error generated.


### EXPECTED OUTPUT:
No diagnostic.


### COMPILER VERSION INFO:
$ clang -v
clang version 3.5.0 (trunk 214060)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Selected multilib: .;@m64

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140817/dee03456/attachment.html>


More information about the llvm-bugs mailing list