From e78eb2f85b9b61cf193dfc721bbd58966bea76df Mon Sep 17 00:00:00 2001 From: Robert Dubner Date: Tue, 19 Aug 2025 23:08:48 -0400 Subject: cobol: Eliminate errors that cause valgrind messages. gcc/cobol/ChangeLog: * genutil.cc (get_binary_value): Fix a comment. * parse.y: udf_args_valid(): Fix loc calculation. * symbols.cc (assert): extend_66_capacity(): Avoid assert(e < e2) in -O0 build until symbol_table expansion is fixed. libgcobol/ChangeLog: * libgcobol.cc (format_for_display_internal): Handle NumericDisplay properly. (compare_88): Fix memory access error. (__gg__unstring): Likewise. --- gcc/cobol/genutil.cc | 2 +- gcc/cobol/parse.y | 5 ++++- gcc/cobol/symbols.cc | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/cobol/genutil.cc b/gcc/cobol/genutil.cc index 3682b10..4b296e4 100644 --- a/gcc/cobol/genutil.cc +++ b/gcc/cobol/genutil.cc @@ -819,7 +819,7 @@ get_binary_value( tree value, } ELSE { - // We are dealing with an ordinary NumericEdited value + // We are dealing with an ordinary NumericDisplay value gg_assign(pointer, source_address); if( rdigits ) diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index 59cc64d..039cb95 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -11959,7 +11959,10 @@ current_t::udf_args_valid( const cbl_label_t *L, if( arg.field ) { // else omitted auto tgt = cbl_field_of(symbol_at(udf.linkage_fields.at(i).isym)); if( ! valid_move(tgt, arg.field) ) { - auto loc = symbol_field_location(field_index(arg.field)); + auto loc = current_location; + if( ! is_temporary(arg.field) ) { + loc = symbol_field_location(field_index(arg.field)); + } error_msg(loc, "FUNCTION %s argument %zu, '%s' cannot be passed to %s, type %s", L->name, i, arg.field->pretty_name(), tgt->pretty_name(), 3 + cbl_field_type_str(tgt->type) ); diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc index f2cd1b5..bbe99b6 100644 --- a/gcc/cobol/symbols.cc +++ b/gcc/cobol/symbols.cc @@ -1598,7 +1598,17 @@ extend_66_capacity( cbl_field_t *alias ) { symbol_elem_t *e = symbol_at(alias->parent); symbol_elem_t *e2 = reinterpret_cast(const_cast(alias->data.picture)); +#ifndef __OPTIMIZE__ +#pragma message "The assert(e < e2) needs fixing" + // The following assert fails when valgrind is involved. This is the known + // problem of expecting mmap() to put new memory maps after older memory + // maps; that assumption fails when valgrind is involved. + + // For now I am defeating the assert when using -O0 so that I can run the + // NIST "make valgrind" tests. But this should be fixed so that the + // symbol table index is used, not the entry locations. assert(e < e2); +#endif alias->data.picture = NULL; capacity_of cap; -- cgit v1.1