[Bug c++/51886] New: __alignof__ on uninstantiated template type

roland at gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Jan 17 20:01:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51886

             Bug #: 51886
           Summary: __alignof__ on uninstantiated template type
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: roland@gnu.org


The attached test case shows a bug when applying __alignof__ to a type that is
part of a template instantiation that has not otherwise been instantiated.

I noticed this on 4.4.3 but reproduced it on today's trunk (r183254).
This case needs to be compiled with -std=c++0x just because it uses
static_assert.

As the comment in the case indicates, simply doing an unrelated instantiation
of the template before the __alignof__ expression is evaluated makes the
problem disappear.

% gcc/g++ -Bgcc/  -S -o - -std=c++0x /tmp/template-align.cc
    .file    "template-align.cc"
/tmp/template-align.cc:9:1: error: static assertion failed: misaligned



More information about the Gcc-bugs mailing list