public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20040] New: A new expression must check the access level of delete operator
@ 2005-02-18  4:11 msadoghi at ca dot ibm dot com
  2005-02-18  4:12 ` [Bug c++/20040] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 7+ messages in thread
From: msadoghi at ca dot ibm dot com @ 2005-02-18  4:11 UTC (permalink / raw)
  To: gcc-bugs

Sourc code for t.cpp:
------------------------------------------------
class X
	{
	void operator delete(void *p) throw ();
	};

X xa;

void X::operator delete(void *p) throw ()
	{
	}

int mymain()
	{
	X *p = new X; /* error - can't access X::operator delete */
	return 0;
	}

------------------------------------------------



Expected Behaviour:
------------------------------------------------
t.cpp:9: `static void X::operator delete(void*)' is private
t.cpp:14: within this context
------------------------------------------------



Actual Behaviour:
------------------------------------------------
None.
------------------------------------------------



t.ii generated with -save-temps option
------------------------------------------------
# 1 "t.cpp"
# 1 "t.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.cpp"
class X
        {
        void operator delete(void *p) throw ();
        };

X xa;

void X::operator delete(void *p) throw ()
        {
        }

int mymain()
        {
        X *p = new X;
        return 0;
        }

------------------------------------------------




Release:
------------------------------------------------
GCC Version: 3.2.0
------------------------------------------------




Environment:
System Type:
------------------------------------------------
Reading specs from /usr/local/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/specs
Configured with: /scratch/gcc-3.2/configure --prefix=/usr/local/gcc.3.2.0
--enable-threads=aix --disable-nls
Thread model: aix
gcc version 3.2
 /usr/local/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/cpp0 -lang-c++
-D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -v -iprefix
/usr/local/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/ -D__GNUC__=3
-D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D_IBMR2
-D_POWER -D_LONG_LONG -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_IBMR2
-D_POWER -D_LONG_LONG -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -Asystem=unix
-Asystem=aix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_XOPEN_SOURCE=500
-D_XOPEN_SOURCE_EXTENDED=1 -D_LARGE_FILE_API -D_ALL_SOURCE
-D__WCHAR_TYPE__=short unsigned int -D_ARCH_COM
/home/msadoghi/scenario/common/t.cpp t.ii
GNU CPP version 3.2 (cpplib)
ignoring nonexistent directory
"/usr/local/lib/gcc-lib/../../powerpc-ibm-aix5.1.0.0/include"
ignoring nonexistent directory "/usr/local/gcc.3.2.0/powerpc-ibm-aix5.1.0.0/include"
ignoring duplicate directory "/usr/local/gcc.3.2.0/include/c++/3.2"
ignoring duplicate directory
"/usr/local/gcc.3.2.0/include/c++/3.2/powerpc-ibm-aix5.1.0.0"
ignoring duplicate directory "/usr/local/gcc.3.2.0/include/c++/3.2/backward"
ignoring duplicate directory
"/usr/local/gcc.3.2.0/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/../../include/c++/3.2
 /usr/local/lib/gcc-lib/../../include/c++/3.2/powerpc-ibm-aix5.1.0.0
 /usr/local/lib/gcc-lib/../../include/c++/3.2/backward
 /usr/local/lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/include
 /usr/local/include
 /usr/local/gcc.3.2.0/include
 /usr/include
End of search list.
 /usr/local/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.2/cc1plus -fpreprocessed
t.ii -quiet -dumpbase t.cpp -version -o t.s
GNU CPP version 3.2 (cpplib)
GNU C++ version 3.2 (powerpc-ibm-aix5.1.0.0)
        compiled by GNU C version 3.2.
/home/msadoghi/scenario/common/t.cpp:2: warning: all member functions in class
   `X' are private
 as -u -mcom -o t.o t.s
------------------------------------------------




How-To-Repeat:
------------------------------------------------
g++ -v -save-temps -c -std=iso9899:199409 t.cpp
------------------------------------------------


Note:
------------------------------------------------
This is a diagnostic test case. Compilation failure is expected. However the
compilation
is successful and no error or warning messages are produced. According to C++
ANSI Standard
the test cases should produces an error. Therefore, in the strict mode compiler
should
produce a server error and in the extended mode it should at least produces a
warning. 

C++ ANSI Standard:
"new-expression that creates object of class type or array thereof must check
access for 
 allocation function, deallocation function, and constructor this checks access 
 for operator delete"

AIX, MACOS and LINUX all have a similar behaviors.
------------------------------------------------

-- 
           Summary: A new expression must check the access level of delete
                    operator
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: msadoghi at ca dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/20040] A new expression must check the access level of delete operator
  2005-02-18  4:11 [Bug c++/20040] New: A new expression must check the access level of delete operator msadoghi at ca dot ibm dot com
@ 2005-02-18  4:12 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-18  4:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-17 21:28 -------
Confirmed, not a regression.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |accepts-invalid
      Known to fail|                            |2.95.3 3.0.4 3.2.3 3.3.3
                   |                            |3.4.0 4.0.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-17 21:28:11
               date|                            |


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


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

* [Bug c++/20040] A new expression must check the access level of delete operator
       [not found] <bug-20040-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2022-01-21 20:18 ` cvs-commit at gcc dot gnu.org
@ 2022-01-28  4:40 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2022-01-28  4:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20040

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |12.0

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 12.

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

* [Bug c++/20040] A new expression must check the access level of delete operator
       [not found] <bug-20040-4@http.gcc.gnu.org/bugzilla/>
  2022-01-06 21:19 ` jason at gcc dot gnu.org
  2022-01-07 22:12 ` cvs-commit at gcc dot gnu.org
@ 2022-01-21 20:18 ` cvs-commit at gcc dot gnu.org
  2022-01-28  4:40 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-21 20:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20040

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:847a8301add0a316767878342c1367948835c181

commit r12-6808-g847a8301add0a316767878342c1367948835c181
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jan 21 12:49:03 2022 -0500

    c++: class array new checking [PR104084]

    My patch for PR20040 made us stop exiting early from build_new_1 in
    cases of trivial initialization if there's a class operator delete; as a
    result, code later in the function needs to handle this case properly.

            PR c++/104084
            PR c++/20040

    gcc/cp/ChangeLog:

            * init.cc (build_new_1): Only pull out TARGET_EXPR_INITIAL if
            alloc_expr is a TARGET_EXPR.

    gcc/testsuite/ChangeLog:

            * g++.dg/init/new50.C: New test.

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

* [Bug c++/20040] A new expression must check the access level of delete operator
       [not found] <bug-20040-4@http.gcc.gnu.org/bugzilla/>
  2022-01-06 21:19 ` jason at gcc dot gnu.org
@ 2022-01-07 22:12 ` cvs-commit at gcc dot gnu.org
  2022-01-21 20:18 ` cvs-commit at gcc dot gnu.org
  2022-01-28  4:40 ` jason at gcc dot gnu.org
  3 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-07 22:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20040

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:6cd51207f5732b5258e883e9030b94c987b6d696

commit r12-6375-g6cd51207f5732b5258e883e9030b94c987b6d696
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 6 16:13:04 2022 -0500

    c++: check delete access with trivial init [PR20040]

    Apparently we need to check the accessibility of the deallocation function
    even if there is no initialization.

            PR c++/20040

    gcc/cp/ChangeLog:

            * init.c (build_new_1): Also build pointer cleanup if
            TYPE_GETS_DELETE.
            * cp-tree.h (TYPE_GETS_VEC_DELETE): New.

    gcc/testsuite/ChangeLog:

            * g++.dg/init/delete4.C: New test.

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

* [Bug c++/20040] A new expression must check the access level of delete operator
       [not found] <bug-20040-4@http.gcc.gnu.org/bugzilla/>
@ 2022-01-06 21:19 ` jason at gcc dot gnu.org
  2022-01-07 22:12 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2022-01-06 21:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20040

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

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

* [Bug c++/20040] A new expression must check the access level of delete operator
       [not found] <bug-20040-10087@http.gcc.gnu.org/bugzilla/>
@ 2006-09-08 20:30 ` amylaar at gcc dot gnu dot org
  0 siblings, 0 replies; 7+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2006-09-08 20:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from amylaar at gcc dot gnu dot org  2006-09-08 20:30 -------
g++ also fails to check the accessibility of the destructor:

class C
{
private:
  void operator delete (void *p)  throw ();
};

void
f ()
{
  C *p = new C;
}

class D
{
private:
  ~D ();
};

void
g ()
{
  D *p = new D;
}


-- 

amylaar at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joern dot rennecke at st dot
                   |                            |com
      Known to fail|2.95.3 3.0.4 3.2.3 3.3.3    |2.95.3 3.0.4 3.2.3 3.3.3
                   |3.4.0 4.0.0                 |3.4.0 4.0.0 4.2.0


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


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

end of thread, other threads:[~2022-01-28  4:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-18  4:11 [Bug c++/20040] New: A new expression must check the access level of delete operator msadoghi at ca dot ibm dot com
2005-02-18  4:12 ` [Bug c++/20040] " pinskia at gcc dot gnu dot org
     [not found] <bug-20040-10087@http.gcc.gnu.org/bugzilla/>
2006-09-08 20:30 ` amylaar at gcc dot gnu dot org
     [not found] <bug-20040-4@http.gcc.gnu.org/bugzilla/>
2022-01-06 21:19 ` jason at gcc dot gnu.org
2022-01-07 22:12 ` cvs-commit at gcc dot gnu.org
2022-01-21 20:18 ` cvs-commit at gcc dot gnu.org
2022-01-28  4:40 ` 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).