public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/116607] New: ICE: tree check: expected tree_list, have integer_cst in has_active_contract_condition, at cp/contracts.cc:1505 with no_sanitize attribute and -fcontracts option
@ 2024-09-05  1:45 iamanonymous.cs at gmail dot com
  2024-09-05  2:13 ` [Bug c++/116607] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: iamanonymous.cs at gmail dot com @ 2024-09-05  1:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116607
           Summary: ICE: tree check: expected tree_list, have integer_cst
                    in has_active_contract_condition, at
                    cp/contracts.cc:1505 with no_sanitize attribute and
                    -fcontracts option
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---

*******************************************************************************
OS and Platform:
$ uname -a:
Linux 65dac7c84719 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC
2023 x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
gcc version:
Using built-in specs.
COLLECT_GCC=/home/software/gcc-trunk-3aa004f/bin/gcc
COLLECT_LTO_WRAPPER=/home/software/gcc-trunk-3aa004f/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++ --prefix=/home/software/gcc-trunk-3aa004f
--enable-coverage
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240630 (experimental) (GCC) 

*******************************************************************************
Program:
$ cat mutant.C
struct a {
  __attribute__((no_sanitize(""))) operator+(b) [[pre]]
} int a::operator+(int) {

This program was reduced by Creduce.

*******************************************************************************
Command Lines:
$ gcc -fcontracts mutant.C
mutant.C:2:46: error: 'b' has not been declared
    2 |   __attribute__((no_sanitize(""))) operator+(b) [[pre]]
      |                                              ^
mutant.C:2:54: error: expected contract semantic or level
    2 |   __attribute__((no_sanitize(""))) operator+(b) [[pre]]
      |                                                      ^
mutant.C:2:54: error: expected ':' before ']' token
    2 |   __attribute__((no_sanitize(""))) operator+(b) [[pre]]
      |                                                      ^
      |                                                      :
mutant.C:2:36: error: ISO C++ forbids declaration of 'operator+' with no type
[-fpermissive]
    2 |   __attribute__((no_sanitize(""))) operator+(b) [[pre]]
      |                                    ^~~~~~~~
mutant.C:2:55: error: expected ';' at end of member declaration
    2 |   __attribute__((no_sanitize(""))) operator+(b) [[pre]]
      |                                                       ^
      |                                                        ;
mutant.C:3:2: error: expected ';' after struct definition
    3 | } int a::operator+(int) {
      |  ^
      |  ;
mutant.C: In member function 'int a::operator+(int)':
mutant.C:2:54: error: expected primary-expression at end of input
    2 |   __attribute__((no_sanitize(""))) operator+(b) [[pre]]
      |                                                      ^
mutant.C:3:23: internal compiler error: tree check: expected tree_list, have
integer_cst in has_active_contract_condition, at cp/contracts.cc:1505
    3 | } int a::operator+(int) {
      |                       ^
0x576c1eb diagnostic_context::report_diagnostic(diagnostic_info*)
        ???:0
0x576cabd diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1],
diagnostic_t)
        ???:0
0x578c98b internal_error(char const*, ...)
        ???:0
0x2d6b950 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0xdca713 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ???:0
0xf98e83 start_function_contracts(tree_node*)
        ???:0
0x104a026 start_preparsed_function(tree_node*, tree_node*, int)
        ???:0
0x104b268 start_function(cp_decl_specifier_seq*, cp_declarator const*,
tree_node*)
        ???:0
0x1378350 c_parse_file()
        ???:0
0x171c898 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Also ICE on trunk.
Compiler Explorer: https://godbolt.org/z/WYhhj7q15

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

* [Bug c++/116607] ICE: tree check: expected tree_list, have integer_cst in has_active_contract_condition, at cp/contracts.cc:1505 with no_sanitize attribute and -fcontracts option
  2024-09-05  1:45 [Bug c/116607] New: ICE: tree check: expected tree_list, have integer_cst in has_active_contract_condition, at cp/contracts.cc:1505 with no_sanitize attribute and -fcontracts option iamanonymous.cs at gmail dot com
@ 2024-09-05  2:13 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-05  2:13 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-09-05
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |c++-contracts,
                   |                            |ice-on-valid-code

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. reduced valid testcase:
```
struct a {
  __attribute__((no_sanitize("")))
  int f(int) [[pre:true]];
};
int a::f(int) {}
```

Looks like there is a missing check for cxx_contract_attribute_p in the loop.


has_active_contract_condition either should use cxx_contract_attribute_p  or
more likely just use CONTRACT_CHAIN .

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

end of thread, other threads:[~2024-09-05  2:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-05  1:45 [Bug c/116607] New: ICE: tree check: expected tree_list, have integer_cst in has_active_contract_condition, at cp/contracts.cc:1505 with no_sanitize attribute and -fcontracts option iamanonymous.cs at gmail dot com
2024-09-05  2:13 ` [Bug c++/116607] " pinskia 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).