Issue 24852 - LDC fails when compile foreach for the target avr.
Summary: LDC fails when compile foreach for the target avr.
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Other
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-10 13:21 UTC by cbleser
Modified: 2024-11-10 14:21 UTC (History)
1 user (show)

See Also:


Attachments
Test program for the AVR processor (298 bytes, application/x-compressed-tar)
2024-11-10 13:29 UTC, cbleser
Details

Note You need to log in before you can comment on or make changes to this issue.
Description cbleser 2024-11-10 13:21:50 UTC

    
Comment 1 cbleser 2024-11-10 13:29:42 UTC
Created attachment 1922 [details]
Test program for the AVR processor

This contains to simple test program
One written in D style and another in C style(D).

The style compiles but the D-style doesn't
Comment 2 cbleser 2024-11-10 13:32:47 UTC
The test program was compiled as follows

D style test

ldc2 -betterC -mtriple=avr -gcc=avr-gcc test.d
Invalid bitcast
  %20 = bitcast i16 %18 to i32
LLVM ERROR: Broken module found, compilation aborted!
#0 0x00006535b26c02e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/carsten/bin/ldc2-1.37.0-linux-x86_64/bin/ldc2+0x6acf2e7)
fish: Job 1, 'ldc2 -betterC -mtriple=avr -gcc…' terminated by signal SIGABRT (Abort)

C style test
ldc2 -betterC -mtriple=avr -gcc=avr-gcc test_ptr.d

The C style compiles fine.
Comment 3 cbleser 2024-11-10 13:52:09 UTC
I just noted that the size_t for the AVR 8-bit processor is uint.
But the process can only address 16 bits so it should properly be ushort and ptrdiff_t should be a short.
Comment 4 Richard (Rikki) Andrew Cattermole 2024-11-10 14:21:15 UTC
The ``size_t`` definition in ldc: https://github.com/ldc-developers/ldc/blob/master/runtime/druntime/src/object.d#L62

Note: ldc bugs need to be filed on ldc's repository, not here.