Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C to V Translator (c2v) Version 0.4.0 Crashes on AtomicExpr Node #184

Open
amiyamandal-dev opened this issue Sep 16, 2024 · 1 comment
Open
Labels
Bug Something isn't working

Comments

@amiyamandal-dev
Copy link

amiyamandal-dev commented Sep 16, 2024

Describe the bug

The C to V translator (c2v) version 0.4.0 is encountering an unhandled expression node of type AtomicExpr while translating the file "sqlite3.c". This causes the translation process to fail, preventing the successful conversion of C code to V code.

C to V translator 0.4.0
  translating /Users/amiyamandal/Desktop/workspace/abc/src/sqlite3.c ... 

Unhandled expr() node {AtomicExpr} (cur_file: "/Users/amiyamandal/Desktop/workspace/abc/src/sqlite3.c"):
&Node{
    id: '0x122338f70'
    kind_str: 'AtomicExpr'
    previous_declaration: ''
    name: ''
    ast_type: AstJsonType{
        desugared_qualified: ''
        qualified: 'void'
    }
    class_modifier: ''
    tags: ''
    initialization_type: ''
    value: ''
    value_number: 0
    opcode: ''
    ast_argument_type: AstJsonType{
        desugared_qualified: ''
        qualified: ''
    }
    declaration_id: ''
    label_id: ''
    is_postfix: false
    location: NodeLocation{
        offset: 0
        file: ''
        line: 0
        source_file: SourceFile{
            offset: 0
            path: ''
        }
        spelling_file: SourceFile{
            offset: 0
            path: ''
        }
        file_index: 0
    }
    comment: ''
    unique_id: 27182
    range: Range{
        begin: Begin{
            offset: 0
            spelling_file: SourceFile{
                offset: 664194
                path: ''
            }
            expansion_file: SourceFile{
                offset: 1281994
                path: ''
            }
        }
        end: End{
            offset: 0
            spelling_file: SourceFile{
                offset: 664239
                path: ''
            }
            expansion_file: SourceFile{
                offset: 1281994
                path: ''
            }
        }
    }
    inner: [<circular>]
    array_filler: []
    ref_declaration: RefDeclarationNode{
        kind_str: ''
        name: ''
        kind: BAD
    }
    kind: AtomicExpr
    current_child_id: 0
    redeclarations_count: 0
}
0   c2v                                 0x0000000100202d50 main__C2V_statement + 1116
1   c2v                                 0x0000000100201b3c main__C2V_statements + 168
2   c2v                                 0x00000001001feaac main__C2V_fn_decl + 3032
3   c2v                                 0x000000010020c820 main__C2V_top_level + 188
4   c2v                                 0x000000010020bbb0 main__C2V_translate_file + 2708
5   c2v                                 0x000000010020b030 main__main + 1564
6   c2v                                 0x00000001002114c0 main + 84
7   dyld                                0x000000018905b154 start + 2476
C2V command: '/Users/amiyamandal/.vmodules/c2v/c2v' 'sqlite3.c'
C2V failed to translate the C files. Please report it via GitHub.

Reproduction Steps

Step 1: Download the SQLite Amalgamation
->Visit the official SQLite website and download the SQLite amalgamation file, specifically sqlite-amalgamation-3460100.zip (or the latest version available).

Step 2: Translate the SQLite Source Code using v command

v translate sqlite3.c

Expected Behavior

should have a file name sqlite3.v with all the v code in it

Current Behavior

empty sqlite3.v

Possible Solution

No response

Additional Information/Context

No response

V version

0.4.7 7baff15

Environment details (OS name and version, etc.)

V full version: V 0.4.7 7baff15
OS: macos, macOS, 14.6.1, 23G93
Processor: 12 cpus, 64bit, little endian, Apple M2 Max

getwd: /Users/amiyamandal/Desktop/workspace/abc/src
vexe: /opt/homebrew/Cellar/vlang/0.4.7/libexec/v
vexe mtime: 2024-07-26 04:41:00

vroot: OK, value: /opt/homebrew/Cellar/vlang/0.4.7/libexec
VMODULES: OK, value: /Users/amiyamandal/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.46.1
Git vroot status: 4.3.21 (60178 commit(s) behind V master)
.git/config present: false

CC version: Apple clang version 15.0.0 (clang-1500.3.9.4)
thirdparty/tcc: N/A

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@amiyamandal-dev amiyamandal-dev added the Bug Something isn't working label Sep 16, 2024
@kbkpbot
Copy link
Contributor

kbkpbot commented Sep 17, 2024

Atomic expr , such as

# define AtomicLoad(PTR)       __atomic_load_n((PTR),__ATOMIC_RELAXED)
# define AtomicStore(PTR,VAL)  __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED)
...
AtomicStore(&mem0.nearlyFull, n>0 && n<=nUsed);
...

can't handle by c2v now.

BTW, you can post c2v issue in https://github.com/vlang/c2v/issues

@JalonSolov JalonSolov transferred this issue from vlang/v Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants