Code violating strict aliasing has been refactored.
libgcobol is now being built with
-fstrict-aliasing -Wstrict-aliasing -Wstrict-aliasing=3
Copyright boilerplate has been updated to the year 2026 throughout gcc/cobol
and libgcobol.
gcc/cobol/ChangeLog:
* cbldiag.h: Copyright updated to 2026.
* cdf-copy.cc: Likewise.
* cdf.y: Likewise.
* cdfval.h: Likewise.
* cobol-system.h: Likewise.
* convert.cc: Likewise.
* copybook.h: Likewise.
* except.cc: Likewise.
* exceptg.h: Likewise.
* genapi.cc: Likewise.
* genapi.h: Likewise.
* gengen.cc: Likewise.
* gengen.h: Likewise.
* genmath.cc: Likewise.
* genmath.h: Likewise.
* genutil.cc: Likewise.
* genutil.h: Likewise.
* inspect.h: Likewise.
* lang-specs.h: Likewise.
* lexio.cc: Likewise.
* lexio.h: Likewise.
* messages.cc: Likewise.
* parse.y: Likewise.
* parse_ante.h: Likewise.
* parse_util.h: Likewise.
* scan.l: Likewise.
* scan_ante.h: Likewise.
* scan_post.h: Likewise.
* show_parse.h: Likewise.
* structs.cc: Likewise.
* structs.h: Likewise.
* symbols.cc: Likewise.
* symbols.h: Likewise.
* symfind.cc: Likewise.
* util.cc: Likewise.
* util.h: Likewise.
libgcobol/ChangeLog:
PR cobol/121499
* LICENSE: Copyright updated to 2026.
* Makefile.am: Compile with -fstrict-aliasing.
* Makefile.in: Autoreconf.
* acinclude.m4: Copyright updated to 2026.
* charmaps.cc: Likewise.
* charmaps.h: Likewise.
* common-defs.h: Likewise.
* configure.tgt: Likewise.
* constants.cc: Likewise.
* ec.h: Likewise.
* encodings.h: Likewise.
* exceptl.h: Likewise.
* gcobolio.h: Likewise.
* gfileio.cc: Likewise.
* gfileio.h: Likewise.
* gmath.cc (multiply_int256_by_int64): Eliminate aliasing.
(divide_int256_by_int64): Likewise.
(multiply_int128_by_int128): Likewise.
(divide_int128_by_int128): Likewise.
* gmath.h: Copyright updated to 2026.
* intrinsic.cc: Likewise.
* io.cc: Likewise.
* io.h: Likewise.
* libgcobol.cc: Likewise.
* libgcobol.h: Likewise.
* stringbin.cc: Likewise.
* stringbin.h: Likewise.
* valconv.cc: Likewise.
* valconv.h: Likewise.
* xmlparse.cc: Likewise.
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
-Copyright (c) 2021-2025 Symas Corporation
+Copyright (c) 2021-2026 Symas Corporation
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
-# Copyright (C) 2025 Free Software Foundation, Inc.
+# Copyright (C) 2026 Free Software Foundation, Inc.
# Contributed by the Symas Corporation, 2025
# This file is part of GCC.
AM_CXXFLAGS = $(XCFLAGS)
AM_CXXFLAGS += $(WARN_CFLAGS)
AM_CXXFLAGS += -DIN_TARGET_LIBS
-AM_CXXFLAGS += -fno-strict-aliasing
-#AM_CXXFLAGS += -fstrict-aliasing -Wstrict-aliasing -Wstrict-aliasing=3
+AM_CXXFLAGS += -fstrict-aliasing -Wstrict-aliasing -Wstrict-aliasing=3
if ENABLE_DARWIN_AT_RPATH
# Handle embedded rpaths for Darwin.
@SET_MAKE@
-# Copyright (C) 2025 Free Software Foundation, Inc.
+# Copyright (C) 2026 Free Software Foundation, Inc.
# Contributed by the Symas Corporation, 2025
# This file is part of GCC.
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
-#AM_CXXFLAGS += -fstrict-aliasing -Wstrict-aliasing -Wstrict-aliasing=3
# Handle embedded rpaths for Darwin.
@BUILD_LIBGCOBOL_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -Wc,-nodefaultrpaths \
@BUILD_LIBGCOBOL_TRUE@ /usr/include/libxml2
@BUILD_LIBGCOBOL_TRUE@AM_CFLAGS = $(XCFLAGS)
@BUILD_LIBGCOBOL_TRUE@AM_CXXFLAGS = $(XCFLAGS) $(WARN_CFLAGS) \
-@BUILD_LIBGCOBOL_TRUE@ -DIN_TARGET_LIBS -fno-strict-aliasing
+@BUILD_LIBGCOBOL_TRUE@ -DIN_TARGET_LIBS -fstrict-aliasing \
+@BUILD_LIBGCOBOL_TRUE@ -Wstrict-aliasing -Wstrict-aliasing=3
# We want to link with the c++ runtime.
@BUILD_LIBGCOBOL_TRUE@libgcobol_la_LINK = $(CXXLINK) $(libgcobol_la_LDFLAGS)
-dnl Copyright (C) 2021-2025 Free Software Foundation, Inc.
+dnl Copyright (C) 2021-2026 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
// This file is included in both the libgcobol and gcc/cobol compilations
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
# -*- shell-script -*-
-# Copyright (C) 2025 Free Software Foundation, Inc.
+# Copyright (C) 2026 Free Software Foundation, Inc.
#
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
- * Copyright (c) 2021_2025 Symas Corporation
+ * Copyright (c) 2021_2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
};
}int256;
+typedef struct int128
+ {
+ union
+ {
+ uint64_t i64 [2];
+ uint128 i128;
+ };
+ }int128;
+
static int
multiply_int256_by_int64(int256 &product, const uint64_t multiplier)
{
// a factor of ten. This is effectively left-shifting by decimal
// digits. See scale_int256_by_digits
uint64_t overflows[5] = {};
+ int128 temp;
for(int i=0; i<4; i++)
{
- uint128 temp = (uint128)product.i64[i] * multiplier;
- product.i64[i] = *PTRCAST(uint64_t, &temp);
- overflows[i+1] = *PTRCAST(uint64_t, PTRCAST(uint8_t, &temp) + 8);
+ // cppcheck-suppress unreadVariable // cppcheck is dumb about unions???
+ temp.i128 = (uint128)product.i64[i] * multiplier;
+ product.i64[i] = temp.i64[0];
+ overflows[i+1] = temp.i64[1];
}
for(int i=1; i<4; i++)
divide_int256_by_int64(int256 &val, uint64_t divisor)
{
// val needs to be a positive number
- uint128 temp = 0;
+ int128 temp = {};
for( int i=3; i>=0; i-- )
{
// Left shift temp 64 bits:
- *PTRCAST(uint64_t, ((PTRCAST(uint8_t, &temp))+8))
- = *PTRCAST(uint64_t, ((PTRCAST(uint8_t, &temp))+0));
+ temp.i64[1] = temp.i64[0];
// Put the high digit of val into the bottom of temp
- *PTRCAST(uint64_t, ((PTRCAST(uint8_t, &temp))+0)) = val.i64[i];
+ temp.i64[0] = val.i64[i];
// Divide that combinary by divisor to get the new digits
- val.i64[i] = temp / divisor;
+ val.i64[i] = temp.i128 / divisor;
// And the new temp is that combination modulo divisor
- temp = temp % divisor;
+ temp.i128 = temp.i128 % divisor;
}
}
uint128 BD;
// Let's extract the digits.
- uint64_t a = *PTRCAST(uint64_t, (PTRCAST(unsigned char, (&ab_value))+8));
- uint64_t b = *PTRCAST(uint64_t, (PTRCAST(unsigned char, (&ab_value))+0));
- uint64_t c = *PTRCAST(uint64_t, (PTRCAST(unsigned char, (&cd_value))+8));
- uint64_t d = *PTRCAST(uint64_t, (PTRCAST(unsigned char, (&cd_value))+0));
+ uint64_t a = ab_value>>64;
+ uint64_t b = ab_value;
+ uint64_t c = cd_value>>64;
+ uint64_t d = cd_value;
// multiply (a0 + b) * (c0 + d)
// Now we multiply our 64-bit guess by the 128-bit CD to get the
// three-place value we are going to subtract from the numerator area.
-
- uint64_t subber[3];
- subber[2] = 0;
+ // We use the bottom three i64[] places of an int256 structure to hold
+ // that three-place value
+ int256 subber;
+ subber.i64[2] = 0;
// Start with the bottom 128 bits of the "subber"
- *PTRCAST(uint128, subber) = (uint128) divisor64[0] * quotient.i64[q_place];
+ subber.i128[0] = (uint128) divisor64[0] * quotient.i64[q_place];
// Get the next 128 bits of subber
temp = (uint128) divisor64[1] * quotient.i64[q_place];
// Add the top of the first product to the bottom of the second:
- subber[1] += temp64[0];
+ subber.i64[1] += temp64[0];
// See if there was an overflow:
- if( subber[1] < temp64[0] )
+ if( subber.i64[1] < temp64[0] )
{
// There was an overflow
- subber[2] = 1;
+ subber.i64[2] = 1;
}
// And now put the top of the second product into place:
- subber[2] += temp64[1];
+ subber.i64[2] += temp64[1];
// "subber" is now the three-place product of the two-place divisor times
// the one-place guess
{
// We are subtracting from zero and we have a borrow. Leave the
// borrow on and just do the subtraction:
- numerator.i64[q_place + j] -= subber[j];
+ numerator.i64[q_place + j] -= subber.i64[j];
}
else
{
uint64_t stash = numerator.i64[q_place + j];
numerator.i64[q_place + j] -= borrow;
- numerator.i64[q_place + j] -= subber[j];
+ numerator.i64[q_place + j] -= subber.i64[j];
if( numerator.i64[q_place + j] > stash )
{
// After subtracting, the value got bigger, which means we have
{
// We are at the top and have a carry. Just leave the carry on
// and do the addition:
- numerator.i64[q_place + ii] += subber[ii];
+ numerator.i64[q_place + ii] += subber.i64[ii];
}
else
{
// We are not at the top.
uint64_t stash = numerator.i64[q_place + ii];
numerator.i64[q_place + ii] += carry;
- numerator.i64[q_place + ii] += subber[ii];
+ numerator.i64[q_place + ii] += subber.i64[ii];
if( numerator.i64[q_place + ii] < stash )
{
// The addition caused the result to get smaller, meaning that
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
// This file is included in both the libgcobol and gcc/cobol compilations
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
/*
- * Copyright (c) 2021-2025 Symas Corporation
+ * Copyright (c) 2021-2026 Symas Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are