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

            Bug ID: 96663
           Summary: Composite type default 'Read attribute does not
                    perform validity checking for defaulted components
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mrhatch97 at gmail dot com
  Target Milestone: ---

Created attachment 49070
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49070&action=edit
Source file for the program demonstrating the bug

System type: Windows x64 (MINGW provided by MSYS2). Target string is
"x86_64-w64-mingw32"

Configured with: ../gcc-10.2.0/configure --prefix=/mingw64
--with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
--with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include
--libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64
--with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++
--enable-shared --enable-static --enable-libatomic --enable-threads=posix
--enable-graphite --enable-fully-dynamic-string
--enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes
--disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check
--enable-lto --enable-libgomp --disable-multilib --enable-checking=release
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --disable-plugin --with-libiconv --with-system-zlib
--with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64
--with-isl=/mingw64 --with-pkgversion='Rev1, Built by MSYS2 project'
--with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as
--with-gnu-ld

Invoked by: gcc -c -gnatVa parse.adb (forwarded from gnat make)

Expected behavior: When run with a text file in the same directory as the
executable with the name "value.txt" containing a single character 'a', the
output "Parse FAILED" should be output to stdout.

This should occur because the default implementation of the 'Read attribute
should raise Constraint_error in the given setup. This behavior is prescribed
by the Ada 2012 Reference Manual (Section 13.13.2, paragraph 35).

The 'Read attribute is invoked for a composite type which contains a single
scalar component with an implicit initial value of 65. The value read from the
file is 'a' (97) which is outside the subtype range of the scalar component.
According to the ARM, Constraint_Error should be raised.

Actual behavior: Under the described circumstances, the output "Parse OK" is
given, followed by "Parsed value is INVALID". No exception is raised, and the
parsed value does not belong to its subtype.

Note: I added -gnatVa to the compile flags to see if that would affect whether
it performed the validity checking, but it didn't change the outcome.

Reply via email to