[Bug c++/56221] New: Generation of zero initializer for array new without parenthesis

neldev.online at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 6 09:23:00 GMT 2013


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

             Bug #: 56221
           Summary: Generation of zero initializer for array new without
                    parenthesis
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: neldev.online@gmail.com


Created attachment 29364
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29364
Minimal test case

I could not find a duplicate so I guess this will be my first bug report for a
compiler :)

I was experimenting a little with expressive templates and stumbled upon a
peculiar bug that caused assembly output to explode by several orders of
magnitude. I managed to narrow it down to automatic vectorization of a zero
initializer that transformed a 4-instruction memset into some monstrosity.
Recompiling with -fno-tree-vectorize prevents this transformation.

However, the issue of this initializer which generated the memset still
remained.

I've attached a minimal test case that performs the following:
- Trigger unwanted generation of the array initializer.
- Triggering automatic vectorization at will by increasing the parameter to
array new beyond 16.
- Preventing the array initializer from being generated by uncommenting the
second constructor.
- Producing identical results by forcing array initializer generation by
uncommenting the third constructor.

A workaround would b to move the array new statement out of the constructor.

I'm not sure but this seems to be the result of some foul play between the CRTP
pattern and operator+. Removing either will prevent this bug from being
triggered.



More information about the Gcc-bugs mailing list