public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52541] New: g++ allows definition of const POD
@ 2012-03-09 11:08 konrad_rudolph at hotmail dot com
  2012-03-09 11:09 ` [Bug c++/52541] " konrad_rudolph at hotmail dot com
  2012-03-09 11:29 ` paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: konrad_rudolph at hotmail dot com @ 2012-03-09 11:08 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52541
           Summary: g++ allows definition of const POD
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: konrad_rudolph@hotmail.com


g++ 4.6.2 compiles the attached code without error. However, it *should* yield
an error similar to "uninitialized const ‘a’" (according to §8.5 of the
standard). In particular, prior versions of GCC treat this as an error,
suggesting a regression. It's also worth noting that the compiler does issue an
error once the class `c` contains member variables.

System: OS X 10.7.3

Configured with: ../configure --prefix=MASKED
--with-gmp=/usr/local/Cellar/gmp/5.0.2/lib/
--with-mpfr=/usr/local/Cellar/mpfr/3.1.0/lib
--with-mpc=/usr/local/Cellar/libmpc/0.9/lib --program-suffix=4.6.2
--enable-languages=c,c++,fortran

Command line: g++-4.6.2 -pedantic main.cpp

Compiler output: none

More information: http://stackoverflow.com/q/9632229/1968, in particular the
discussion in the comments.


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

* [Bug c++/52541] g++ allows definition of const POD
  2012-03-09 11:08 [Bug c++/52541] New: g++ allows definition of const POD konrad_rudolph at hotmail dot com
@ 2012-03-09 11:09 ` konrad_rudolph at hotmail dot com
  2012-03-09 11:29 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: konrad_rudolph at hotmail dot com @ 2012-03-09 11:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Konrad Rudolph <konrad_rudolph at hotmail dot com> 2012-03-09 11:09:23 UTC ---
Created attachment 26860
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26860
MWE


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

* [Bug c++/52541] g++ allows definition of const POD
  2012-03-09 11:08 [Bug c++/52541] New: g++ allows definition of const POD konrad_rudolph at hotmail dot com
  2012-03-09 11:09 ` [Bug c++/52541] " konrad_rudolph at hotmail dot com
@ 2012-03-09 11:29 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-09 11:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-09 11:29:04 UTC ---
This behavior changed on purpose, see testcase: g++.dg/init/const8.C.

2011-09-23  Jason Merrill  <jason@redhat.com>

    Core 253 - allow const objects with no initializer or
    user-provided default constructor if the defaulted constructor
    initializes all the subobjects.
    PR c++/20039
    PR c++/42844
    * class.c (default_init_uninitialized_part): New.
    * cp-tree.h: Declare it.
    * decl.c (check_for_uninitialized_const_var): Use it.
    * init.c (perform_member_init): Likewise.
    (build_new_1): Likewise.
    * method.c (walk_field_subobs): Likewise.


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

end of thread, other threads:[~2012-03-09 11:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-09 11:08 [Bug c++/52541] New: g++ allows definition of const POD konrad_rudolph at hotmail dot com
2012-03-09 11:09 ` [Bug c++/52541] " konrad_rudolph at hotmail dot com
2012-03-09 11:29 ` paolo.carlini at oracle dot com

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