public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50015] New: std::initializer_list<std::string> members are not properly initialized
@ 2011-08-07 15:48 danny.dyk@tu-dortmund.de
  2011-08-07 15:50 ` [Bug c++/50015] " danny.dyk@tu-dortmund.de
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: danny.dyk@tu-dortmund.de @ 2011-08-07 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: std::initializer_list<std::string> members are not
                    properly initialized
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: danny.dyk@tu-dortmund.de


Created attachment 24940
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24940
Output of 'g++ -std=c++0x -save-temps -o test-case test-case.cc'

When creating a std::initializer_list<std::string> as part of a struct, the
actual
object is not properly initialized. Consider the following test case:

-- BEGIN --
#include <initializer_list>
#include <iostream>
#include <string>

struct T
{
    std::initializer_list<std::string> s;
};

T foo
{
    {"foo", "bar", "baz"}
};

int main(int, char**)
{
    for (auto t = foo.s.begin(), t_end = foo.s.end() ; t != t_end ; ++t)
        std::cout << *t << std::endl;

    return 0;
}
-- END --

After compiling this test case using

  g++ -Wall -pedantic -std=c++0x -o test-case test-case.cc
  [no errors, no warnings]

the execution of the resulting binary via

  ./test-case

either raises a segmentation fault or produces garbled output, e.g.,

  foo1`particularÿÿÿÿbar1ÿÿ

Looks very much like terminating '\0's are not in place.

This bug was first seen when using gcc-4.4.5 and is reproducable under
gcc-4.5.0
up to gcc-4.6.1. The particular version of gcc-4.6.1 was configured as

 configure \
    --prefix=/het/packages/gcc-${VERSION} \
    --program-prefix=het- \
    --program-suffix=-${VERSION} \
    --enable-languages=c,c++ \
    --disable-multilib

and built on an amd64 system.

I will attach the output of

  g++ -std=c++0x -save-temps -o test-case test-case.cc
  g++ -std=c++0x -fdump-tree-gimple -o test-case test-case.cc

to this bug report.

Thank you to Alexander Faeroey for help in reducing the segfaulting code to
a manageable test case.


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

* [Bug c++/50015] std::initializer_list<std::string> members are not properly initialized
  2011-08-07 15:48 [Bug c++/50015] New: std::initializer_list<std::string> members are not properly initialized danny.dyk@tu-dortmund.de
@ 2011-08-07 15:50 ` danny.dyk@tu-dortmund.de
  2011-08-07 16:38 ` [Bug c++/50015] [C++0x] " paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: danny.dyk@tu-dortmund.de @ 2011-08-07 15:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Danny van Dyk <danny.dyk@tu-dortmund.de> 2011-08-07 15:49:43 UTC ---
Created attachment 24941
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24941
Output of 'g++ -std=c++0x -fdump-tree-gimple -o test-case test-case.cc'


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

* [Bug c++/50015] [C++0x] std::initializer_list<std::string> members are not properly initialized
  2011-08-07 15:48 [Bug c++/50015] New: std::initializer_list<std::string> members are not properly initialized danny.dyk@tu-dortmund.de
  2011-08-07 15:50 ` [Bug c++/50015] " danny.dyk@tu-dortmund.de
@ 2011-08-07 16:38 ` paolo.carlini at oracle dot com
  2011-08-08 13:55 ` jason at gcc dot gnu.org
  2011-11-04 16:26 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-08-07 16:38 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
            Summary|std::initializer_list<std:: |[C++0x]
                   |string> members are not     |std::initializer_list<std::
                   |properly initialized        |string> members are not
                   |                            |properly initialized

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-07 16:38:30 UTC ---
Also basing on the errors produced by valgrind, seems related to PR48370. Jason
can you have a look / maybe close as duplicate?


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

* [Bug c++/50015] [C++0x] std::initializer_list<std::string> members are not properly initialized
  2011-08-07 15:48 [Bug c++/50015] New: std::initializer_list<std::string> members are not properly initialized danny.dyk@tu-dortmund.de
  2011-08-07 15:50 ` [Bug c++/50015] " danny.dyk@tu-dortmund.de
  2011-08-07 16:38 ` [Bug c++/50015] [C++0x] " paolo.carlini at oracle dot com
@ 2011-08-08 13:55 ` jason at gcc dot gnu.org
  2011-11-04 16:26 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-08-08 13:55 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-08-08 13:54:30 UTC ---
Yep, same bug.

*** This bug has been marked as a duplicate of bug 48370 ***


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

* [Bug c++/50015] [C++0x] std::initializer_list<std::string> members are not properly initialized
  2011-08-07 15:48 [Bug c++/50015] New: std::initializer_list<std::string> members are not properly initialized danny.dyk@tu-dortmund.de
                   ` (2 preceding siblings ...)
  2011-08-08 13:55 ` jason at gcc dot gnu.org
@ 2011-11-04 16:26 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-04 16:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-04 16:26:11 UTC ---
I verified that my patch for 48370 also fixes this testcase.


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

end of thread, other threads:[~2011-11-04 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-07 15:48 [Bug c++/50015] New: std::initializer_list<std::string> members are not properly initialized danny.dyk@tu-dortmund.de
2011-08-07 15:50 ` [Bug c++/50015] " danny.dyk@tu-dortmund.de
2011-08-07 16:38 ` [Bug c++/50015] [C++0x] " paolo.carlini at oracle dot com
2011-08-08 13:55 ` jason at gcc dot gnu.org
2011-11-04 16:26 ` jason at gcc dot gnu.org

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).